From eb0fbe519c4801f97d9eaecc9ac5ff65ff124e7e Mon Sep 17 00:00:00 2001 From: Dan Hansen <mokker1234@gmail.com> Date: Sat, 2 Jul 2011 16:39:01 -0700 Subject: [PATCH] remove read/unread state, always mark notifications as read, only return 5 notifications for json requests --- app/controllers/notifications_controller.rb | 2 +- .../widgets/notifications-badge.js | 24 ++++++++++++++++--- public/stylesheets/sass/application.sass | 4 ---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index af52b16a30..52c5bd3f7c 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -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 ) diff --git a/public/javascripts/widgets/notifications-badge.js b/public/javascripts/widgets/notifications-badge.js index ff2d0ad812..72301de067 100644 --- a/public/javascripts/widgets/notifications-badge.js +++ b/public/javascripts/widgets/notifications-badge.js @@ -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(); + } + }); + } }); }); }; diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index a9b5c6b371..247d030dc1 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -3082,10 +3082,6 @@ ul.left_nav .notification_element :padding 10px 20px :min-height 30px - .unread - :background #CCC - .read - :background white img :height 30px -- GitLab