-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: Actually show more notifications
The "Show more notifications..." link in the notifications dropdown now links to /my/notifications, which is a historical view of all notifications you have recieved. Notification history is loaded in blocks of 60 at a time. Admins can see others' notification history. (This was requested for 'debugging purposes', though that's what impersonation is for, IMO.)
- Loading branch information
Showing
20 changed files
with
246 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/assets/javascripts/discourse/controllers/user-notifications.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
export default Ember.ArrayController.extend({ | ||
canLoadMore: true, | ||
loading: false, | ||
|
||
actions: { | ||
loadMore: function() { | ||
if (this.get('canLoadMore') && !this.get('loading')) { | ||
this.set('loading', true); | ||
var self = this; | ||
Discourse.NotificationContainer.loadHistory( | ||
self.get('model.lastObject.created_at'), | ||
self.get('user.username')).then(function(result) { | ||
self.set('loading', false); | ||
self.pushObjects(result); | ||
// Stop trying if it's the end | ||
if (result.length === 0) { | ||
self.set('canLoadMore', false); | ||
} | ||
}).catch(function(error) { | ||
self.set('loading', false); | ||
Em.Logger.error(error); | ||
}); | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Discourse.NotificationContainer = Ember.ArrayProxy.extend({ | ||
|
||
}); | ||
|
||
Discourse.NotificationContainer.reopenClass({ | ||
|
||
createFromJson: function(json_array) { | ||
return Discourse.NotificationContainer.create({content: json_array}); | ||
}, | ||
|
||
createFromError: function(error) { | ||
return Discourse.NotificationContainer.create({ | ||
content: [], | ||
error: true, | ||
forbidden: error.status === 403 | ||
}); | ||
}, | ||
|
||
loadRecent: function() { | ||
return Discourse.ajax('/notifications').then(function(result) { | ||
return Discourse.NotificationContainer.createFromJson(result); | ||
}).catch(function(error) { | ||
// HeaderController can't handle it properly | ||
throw error; | ||
}); | ||
}, | ||
|
||
loadHistory: function(beforeDate, username) { | ||
var url = '/notifications/history.json', | ||
params = [ | ||
beforeDate ? ('before=' + beforeDate) : null, | ||
username ? ('user=' + username) : null | ||
]; | ||
|
||
// Remove nulls | ||
params = params.filter(function(param) { return !!param; }); | ||
// Build URL | ||
params.forEach(function(param, idx) { | ||
url = url + (idx === 0 ? '?' : '&') + param; | ||
}); | ||
|
||
return Discourse.ajax(url).then(function(result) { | ||
return Discourse.NotificationContainer.createFromJson(result); | ||
}).catch(function(error) { | ||
return Discourse.NotificationContainer.createFromError(error); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/assets/javascripts/discourse/routes/user-notifications.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export default Discourse.Route.extend({ | ||
model: function() { | ||
var user = this.modelFor('user'); | ||
return Discourse.NotificationContainer.loadHistory(undefined, user.get('username')); | ||
}, | ||
|
||
setupController: function(controller, model) { | ||
this.controllerFor('user').set('indexStream', false); | ||
if (this.controllerFor('user_activity').get('content')) { | ||
this.controllerFor('user_activity').set('userActionType', -1); | ||
} | ||
controller.set('model', model); | ||
controller.set('user', this.modelFor('user')); | ||
}, | ||
|
||
renderTemplate: function() { | ||
this.render('user-notification-history', {into: 'user', outlet: 'userOutlet'}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/assets/javascripts/discourse/templates/user/notifications.js.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{{#if model.error}} | ||
<div class="item error"> | ||
{{#if model.forbidden}} | ||
{{i18n errors.reasons.forbidden}} | ||
{{else}} | ||
{{i18n errors.desc.unknown}} | ||
{{/if}} | ||
</div> | ||
{{/if}} | ||
|
||
{{#each itemController="notification"}} | ||
<div {{bind-attr class=":item :notification read::unread"}}> | ||
{{notification-item notification=this scope=scope}} | ||
<span class="time"> | ||
{{date path="created_at" leaveAgo="true"}} | ||
</span> | ||
</div> | ||
{{/each}} | ||
{{#if loading}} | ||
<div class='spinner'>{{i18n loading}}</div> | ||
{{/if}} | ||
{{#unless canLoadMore}} | ||
<div class='end-of-stream'></div> | ||
{{/unless}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
app/assets/javascripts/discourse/views/user-notification-history.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default Ember.View.extend(Discourse.LoadMore, { | ||
eyelineSelector: '.user-stream .notification', | ||
classNames: ['user-stream', 'notification-history'], | ||
templateName: 'user/notifications' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,11 @@ | |
} | ||
} | ||
|
||
.end-of-stream { | ||
border: 3px solid $primary; | ||
width: 100%; | ||
} | ||
|
||
.user-navigation { | ||
|
||
.map { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.