Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timeago for notifications, add 'no notifications yet' message #5417

Merged
merged 1 commit into from Feb 10, 2015

Conversation

@svbergerem
Copy link
Member

commented Nov 23, 2014

@@ -9,6 +9,9 @@ app.views.Notifications = Backbone.View.extend({
initialize: function() {
Diaspora.page.header.notifications.setUpNotificationPage(this);
$(".unread-toggle .entypo").tooltip();
$("time.timeago").each(function(i,e) {
$(e).attr('title', new Date($(e).attr('datetime')).toLocaleString())
}).timeago().tooltip();

This comment has been minimized.

Copy link
@svbergerem

svbergerem Nov 23, 2014

Author Member

We have the same code for the notifications badge (see this PR), as well as the conversations: https://github.com/diaspora/diaspora/blob/develop/app/views/conversations/show.js.erb#L13 https://github.com/diaspora/diaspora/blob/develop/app/assets/javascripts/app/views/conversations_view.js#L21

I thought about moving that code to a helper function but the functions in /app/assets/javascripts/app/helpers/ look completely different because they don't directly change stuff in the views. Any ideas?

This comment has been minimized.

Copy link
@svbergerem

svbergerem Dec 1, 2014

Author Member

@Raven24 ping

@svbergerem svbergerem force-pushed the svbergerem:notifications-fix-timeago branch from e5c341a to 7f8091e Feb 9, 2015

@@ -0,0 +1,9 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Line is too long.

describe("app.helpers.timeago", function() {
beforeEach(function(){
this.content = spec.content();
this.content.html('<time class="timeago" datetime="2015-02-08T13:37:42.000Z"></time>');

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Line is too long.
Mixed double and single quotes.

this.content.html('<time class="timeago" datetime="2015-02-08T13:37:42.000Z"></time>');
});
it("converts the date into a locale string for the tooltip", function() {
expect(this.content.find('time.timeago').attr('datetime')).toEqual('2015-02-08T13:37:42.000Z');

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Line is too long.
Mixed double and single quotes.

});
it("converts the date into a locale string for the tooltip", function() {
expect(this.content.find('time.timeago').attr('datetime')).toEqual('2015-02-08T13:37:42.000Z');
expect(this.content.find('time.timeago').data('original-title')).toEqual(undefined);

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Line is too long.
Mixed double and single quotes.

expect(this.content.find('time.timeago').attr('datetime')).toEqual('2015-02-08T13:37:42.000Z');
expect(this.content.find('time.timeago').data('original-title')).toEqual(undefined);
app.helpers.timeago(this.content);
expect(this.content.find('time.timeago').attr('datetime')).toEqual('2015-02-08T13:37:42.000Z');

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Line is too long.
Mixed double and single quotes.

expect(this.content.find('time.timeago').data('original-title')).toEqual(undefined);
app.helpers.timeago(this.content);
expect(this.content.find('time.timeago').attr('datetime')).toEqual('2015-02-08T13:37:42.000Z');
expect(this.content.find('time.timeago').data('original-title')).toEqual('8.2.2015 14:37:42');

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Line is too long.
Mixed double and single quotes.

@svbergerem svbergerem force-pushed the svbergerem:notifications-fix-timeago branch from 7f8091e to 3312f97 Feb 9, 2015

@@ -0,0 +1,20 @@
describe("app.helpers.timeago", function() {
beforeEach(function(){
this.date = '2015-02-08T13:37:42.000Z';

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Mixed double and single quotes.

beforeEach(function(){
this.date = '2015-02-08T13:37:42.000Z';
this.datestring = new Date(this.date).toLocaleString();
var html = '<time class="timeago" datetime="' + this.date + '"></time>';

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Mixed double and single quotes.

it("converts the date into a locale string for the tooltip", function() {
var timeago = this.content.find('time.timeago');
expect(timeago.attr('datetime')).toEqual(this.date);
expect(timeago.data('original-title')).toEqual(undefined);

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Mixed double and single quotes.


app.helpers.timeago(this.content);

timeago = this.content.find('time.timeago');

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Mixed double and single quotes.

app.helpers.timeago(this.content);

timeago = this.content.find('time.timeago');
expect(timeago.attr('datetime')).toEqual(this.date);

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Mixed double and single quotes.


timeago = this.content.find('time.timeago');
expect(timeago.attr('datetime')).toEqual(this.date);
expect(timeago.data('original-title')).toEqual(this.datestring);

This comment has been minimized.

Copy link
@houndci-bot

houndci-bot Feb 9, 2015

Mixed double and single quotes.

@svbergerem

This comment has been minimized.

Copy link
Member Author

commented Feb 9, 2015

I moved the code to a helper function and added a test. Should be ready to merge now.

@jhass jhass added this to the next-major milestone Feb 10, 2015

jhass added a commit that referenced this pull request Feb 10, 2015

Merge pull request #5417 from svbergerem/notifications-fix-timeago
Fix timeago for notifications, add 'no notifications yet' message

@jhass jhass merged commit dece3cf into diaspora:develop Feb 10, 2015

2 checks passed

continuous-integration/travis-ci The Travis CI build passed
Details
hound Hound has reviewed the changes.
@jhass

This comment has been minimized.

Copy link
Member

commented Feb 10, 2015

Thanks!

@svbergerem svbergerem deleted the svbergerem:notifications-fix-timeago branch Feb 10, 2015

@svbergerem svbergerem referenced this pull request Feb 10, 2015
4 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.