remove read/unread state, always mark notifications as read, only return 5 notifications for json requests

This commit is contained in:
Dan Hansen 2011-07-02 16:39:01 -07:00
parent 0b56ade468
commit eb0fbe519c
3 changed files with 22 additions and 8 deletions

View file

@ -24,7 +24,7 @@ class NotificationsController < VannaController
:conditions => conditions,
:order => 'created_at desc',
:include => [:target, {:actors => :profile}],
:limit => pager.per_page,
:limit => request.format == :json ? 5 : pager.per_page,
:offset => pager.offset
)

View file

@ -14,6 +14,7 @@
evt.stopPropagation();
self.getNotifications(function() {
self.badge.addClass("active");
self.renderNotifications();
self.dropdown.css("display", "block");
});
@ -21,6 +22,7 @@
evt.preventDefault();
evt.stopPropagation();
self.badge.removeClass("active");
self.dropdown.css("display", "none");
});
@ -52,12 +54,28 @@
$.each(self.notifications.notifications, function(index, notifications) {
$.each(notifications, function(index, notification) {
$("<div/>")
var notificationElement = $("<div/>")
.addClass("notification_element")
.addClass((notification.unread) ? "unread" : "read" )
.html(notification.translation)
.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();
}
});
}
});
});
};

View file

@ -3082,10 +3082,6 @@ ul.left_nav
.notification_element
:padding 10px 20px
:min-height 30px
.unread
:background #CCC
.read
:background white
img
:height 30px