diff --git a/app/assets/javascripts/discourse/components/notification-item.js.es6 b/app/assets/javascripts/discourse/components/notification-item.js.es6
index 40bf11f0232..c587e12b6d0 100644
--- a/app/assets/javascripts/discourse/components/notification-item.js.es6
+++ b/app/assets/javascripts/discourse/components/notification-item.js.es6
@@ -14,6 +14,11 @@ export default Ember.Component.extend({
var notification = this.get('notification'),
text = I18n.t(this.get('scope'), Em.getProperties(notification, 'description', 'username'));
- buffer.push('' + text + '');
+ var url = notification.get('url');
+ if (url) {
+ buffer.push('' + text + '');
+ } else {
+ buffer.push(text);
+ }
}
});
diff --git a/app/assets/javascripts/discourse/controllers/header.js.es6 b/app/assets/javascripts/discourse/controllers/header.js.es6
index 0a6af7f6e53..90798d38f6b 100644
--- a/app/assets/javascripts/discourse/controllers/header.js.es6
+++ b/app/assets/javascripts/discourse/controllers/header.js.es6
@@ -10,13 +10,13 @@ export default Discourse.Controller.extend({
topic: null,
showExtraInfo: null,
notifications: null,
- loading_notifications: null,
+ loadingNotifications: false,
showStarButton: function() {
return Discourse.User.current() && !this.get('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");
@@ -36,18 +36,16 @@ export default Discourse.Controller.extend({
refreshNotifications: function(){
var self = this;
+ if (self.get("loadingNotifications")) { return; }
- if(self.get("loading_notifications")){return;}
-
- self.set("loading_notifications", true);
+ self.set("loadingNotifications", true);
Discourse.ajax("/notifications").then(function(result) {
- self.set('currentUser.unread_notifications', 0);
self.setProperties({
- notifications: result,
- loading_notifications: false
+ 'currentUser.unread_notifications': 0,
+ notifications: result
});
- }, function(){
- self.set("loading_notifications", false);
+ }).finally(function(){
+ self.set("loadingNotifications", false);
});
},
diff --git a/app/assets/javascripts/discourse/controllers/notification.js.es6 b/app/assets/javascripts/discourse/controllers/notification.js.es6
index f4d6e970da1..bd49498e149 100644
--- a/app/assets/javascripts/discourse/controllers/notification.js.es6
+++ b/app/assets/javascripts/discourse/controllers/notification.js.es6
@@ -17,15 +17,18 @@ export default Discourse.ObjectController.extend({
if (badgeId) {
var badgeName = this.safe("data.badge_name");
return '/badges/' + badgeId + '/' + badgeName.replace(/[^A-Za-z0-9_]+/g, '-').toLowerCase();
- } else {
- return Discourse.Utilities.postUrl(this.safe("slug"), this.safe("topic_id"), this.safe("post_number"));
}
- }.property("data.@{badge_id, badge_name}", "slug", "topic_id", "post_number"),
+
+ var topicId = this.safe('topic_id');
+ if (topicId) {
+ return Discourse.Utilities.postUrl(this.safe("slug"), topicId, this.safe("post_number"));
+ }
+ }.property("data.{badge_id, badge_name}", "slug", "topic_id", "post_number"),
description: function () {
var badgeName = this.safe("data.badge_name");
if (badgeName) { return badgeName; }
return this.blank("data.topic_title") ? "" : this.safe("data.topic_title");
- }.property("data.@{badge_name, topic_title}")
+ }.property("data.{badge_name, topic_title}")
});
diff --git a/app/assets/javascripts/discourse/controllers/notifications.js.es6 b/app/assets/javascripts/discourse/controllers/notifications.js.es6
index 9276251382d..300d22b01a4 100644
--- a/app/assets/javascripts/discourse/controllers/notifications.js.es6
+++ b/app/assets/javascripts/discourse/controllers/notifications.js.es6
@@ -1,4 +1,4 @@
export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
needs: ['header'],
- itemController: "notification"
+ loadingNotifications: Em.computed.alias('controllers.header.loadingNotifications')
});
diff --git a/app/assets/javascripts/discourse/templates/notifications.js.handlebars b/app/assets/javascripts/discourse/templates/notifications.js.handlebars
index 1ad8a997be0..e2220200519 100644
--- a/app/assets/javascripts/discourse/templates/notifications.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/notifications.js.handlebars
@@ -1,8 +1,8 @@
- {{#unless controllers.header.loading_notifications}}
+ {{#unless loadingNotifications}}
{{#if content}}
- {{#each}}
+ {{#each itemController="notification"}}
{{notification-item notification=this scope=scope}}
{{/each}}
-
diff --git a/test/javascripts/controllers/notifications-test.js.es6 b/test/javascripts/controllers/notifications-test.js.es6
index f30af6f0a5d..ed87b1d43f3 100644
--- a/test/javascripts/controllers/notifications-test.js.es6
+++ b/test/javascripts/controllers/notifications-test.js.es6
@@ -5,7 +5,3 @@ moduleFor('controller:notifications', 'controller:notifications', {
test("mixes in HasCurrentUser", function() {
ok(Discourse.HasCurrentUser.detect(this.subject()));
});
-
-test("by default uses NotificationController as its item controller", function() {
- equal(this.subject().get("itemController"), "notification");
-});