remove read/unread state, always mark notifications as read, only return 5 notifications for json requests
This commit is contained in:
parent
0b56ade468
commit
eb0fbe519c
3 changed files with 22 additions and 8 deletions
|
|
@ -24,7 +24,7 @@ class NotificationsController < VannaController
|
||||||
:conditions => conditions,
|
:conditions => conditions,
|
||||||
:order => 'created_at desc',
|
:order => 'created_at desc',
|
||||||
:include => [:target, {:actors => :profile}],
|
:include => [:target, {:actors => :profile}],
|
||||||
:limit => pager.per_page,
|
:limit => request.format == :json ? 5 : pager.per_page,
|
||||||
:offset => pager.offset
|
:offset => pager.offset
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
|
|
||||||
self.getNotifications(function() {
|
self.getNotifications(function() {
|
||||||
|
self.badge.addClass("active");
|
||||||
self.renderNotifications();
|
self.renderNotifications();
|
||||||
self.dropdown.css("display", "block");
|
self.dropdown.css("display", "block");
|
||||||
});
|
});
|
||||||
|
|
@ -21,6 +22,7 @@
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
|
|
||||||
|
self.badge.removeClass("active");
|
||||||
self.dropdown.css("display", "none");
|
self.dropdown.css("display", "none");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -52,12 +54,28 @@
|
||||||
|
|
||||||
$.each(self.notifications.notifications, function(index, notifications) {
|
$.each(self.notifications.notifications, function(index, notifications) {
|
||||||
$.each(notifications, function(index, notification) {
|
$.each(notifications, function(index, notification) {
|
||||||
$("<div/>")
|
var notificationElement = $("<div/>")
|
||||||
.addClass("notification_element")
|
.addClass("notification_element")
|
||||||
.addClass((notification.unread) ? "unread" : "read" )
|
|
||||||
.html(notification.translation)
|
.html(notification.translation)
|
||||||
.prepend($("<img/>", { src: notification.actors[0].avatar }))
|
.prepend($("<img/>", { src: notification.actors[0].avatar }))
|
||||||
.prependTo(self.dropdownNotifications);
|
.append("<br />")
|
||||||
|
.append($("<abbr/>", {
|
||||||
|
"class": "timeago",
|
||||||
|
"title": notification.created_at
|
||||||
|
}))
|
||||||
|
.appendTo(self.dropdownNotifications);
|
||||||
|
|
||||||
|
Diaspora.widgets.timeago.updateTimeAgo(".notification_element time.timeago");
|
||||||
|
|
||||||
|
if(notification.unread) {
|
||||||
|
$.ajax({
|
||||||
|
url: "/notifications/" + notification.id,
|
||||||
|
type: "PUT",
|
||||||
|
success: function() {
|
||||||
|
Diaspora.widgets.notifications.decrementCount();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3082,10 +3082,6 @@ ul.left_nav
|
||||||
.notification_element
|
.notification_element
|
||||||
:padding 10px 20px
|
:padding 10px 20px
|
||||||
:min-height 30px
|
:min-height 30px
|
||||||
.unread
|
|
||||||
:background #CCC
|
|
||||||
.read
|
|
||||||
:background white
|
|
||||||
|
|
||||||
img
|
img
|
||||||
:height 30px
|
:height 30px
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue