mirror of
https://github.com/discourse/discourse.git
synced 2025-02-04 10:53:01 +08:00
8f390c979b
Added a Mark All as Read button to the top/bottom of the notifications user page https://meta.discourse.org/t/possibility-to-selectively-or-completely-mark-notifications-as-read/20227 Remove notifications property (no longer used)
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
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() {
|
|
// TODO - add .json (breaks tests atm)
|
|
return Discourse.ajax('/notifications').then(function(result) {
|
|
return Discourse.NotificationContainer.createFromJson(result);
|
|
}).catch(function(error) {
|
|
// TODO HeaderController can't handle a createFromError
|
|
// just throw for now
|
|
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);
|
|
});
|
|
},
|
|
|
|
resetNew: function() {
|
|
return Discourse.ajax("/notifications/reset-new", {type: 'PUT'});
|
|
}
|
|
});
|