BUGFIX: notifications cleared incorrectly
The notifications panel would reset itself if you got a notification while it was open New behavior, we refresh the panel live, blue notification is cleared automatically if its open. If window is not visible it will close the notifications panel, that way you don't miss notifications by accident.
This commit is contained in:
parent
8d04e54198
commit
2042ed02ec
|
@ -17,9 +17,40 @@ export default Discourse.Controller.extend({
|
||||||
}.property('topic.isPrivateMessage'),
|
}.property('topic.isPrivateMessage'),
|
||||||
|
|
||||||
resetCachedNotifications: function(){
|
resetCachedNotifications: function(){
|
||||||
|
// a bit hacky, but if we have no focus, hide notifications first
|
||||||
|
var visible = $("#notifications-dropdown").is(":visible");
|
||||||
|
|
||||||
|
if(!Discourse.get("hasFocus")) {
|
||||||
|
if(visible){
|
||||||
|
$("html").click();
|
||||||
|
}
|
||||||
this.set("notifications", null);
|
this.set("notifications", null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(visible){
|
||||||
|
this.refreshNotifications();
|
||||||
|
} else {
|
||||||
|
this.set("notifications", null);
|
||||||
|
}
|
||||||
}.observes("currentUser.lastNotificationChange"),
|
}.observes("currentUser.lastNotificationChange"),
|
||||||
|
|
||||||
|
refreshNotifications: function(){
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
if(self.get("loading_notifications")){return;}
|
||||||
|
|
||||||
|
self.set("loading_notifications", true);
|
||||||
|
Discourse.ajax("/notifications").then(function(result) {
|
||||||
|
self.set('currentUser.unread_notifications', 0);
|
||||||
|
self.setProperties({
|
||||||
|
notifications: result,
|
||||||
|
loading_notifications: false
|
||||||
|
});
|
||||||
|
}, function(){
|
||||||
|
self.set("loading_notifications", false);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
toggleStar: function() {
|
toggleStar: function() {
|
||||||
var topic = this.get('topic');
|
var topic = this.get('topic');
|
||||||
|
@ -31,15 +62,7 @@ export default Discourse.Controller.extend({
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (self.get('currentUser.unread_notifications') || self.get('currentUser.unread_private_messages') || !self.get('notifications')) {
|
if (self.get('currentUser.unread_notifications') || self.get('currentUser.unread_private_messages') || !self.get('notifications')) {
|
||||||
self.set("loading_notifications", true);
|
self.refreshNotifications();
|
||||||
Discourse.ajax("/notifications").then(function(result) {
|
|
||||||
self.set('currentUser.unread_notifications', 0);
|
|
||||||
|
|
||||||
self.setProperties({
|
|
||||||
notifications: result,
|
|
||||||
loading_notifications: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
headerView.showDropdownBySelector("#user-notifications");
|
headerView.showDropdownBySelector("#user-notifications");
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue