From e7c3b0ad939b4754bd546b67555f822c0bd3c8c6 Mon Sep 17 00:00:00 2001 From: Scotty Allen Date: Thu, 4 Jun 2015 17:10:38 -0700 Subject: [PATCH] Make unread messages badges only show mentions It used to show count of all unread messages. Instead, now channel names go bold and white if there are unread messages, but the count next to them only shows the number of mentions. The favicon and page title only show the total number of mentions. This is an enhancement described in #122. --- client/startup/startup.coffee | 12 ++++++------ client/stylesheets/base.less | 8 ++++++-- client/views/app/sideNav/chatRoomItem.coffee | 6 ++++++ client/views/app/sideNav/chatRoomItem.html | 6 +++--- server/methods/addUserToRoom.coffee | 1 + server/methods/canAccessRoom.coffee | 1 + server/methods/createChannel.coffee | 1 + server/methods/createDirectRoom.coffee | 2 ++ server/methods/createPrivateGroup.coffee | 1 + server/methods/readMessages.coffee | 2 +- server/methods/sendMessage.coffee | 12 ++++++++++++ server/methods/setUsername.coffee | 1 + 12 files changed, 41 insertions(+), 12 deletions(-) diff --git a/client/startup/startup.coffee b/client/startup/startup.coffee index 58ff5cbe5d9a..20b1783f4203 100644 --- a/client/startup/startup.coffee +++ b/client/startup/startup.coffee @@ -81,15 +81,15 @@ Meteor.startup -> KonchatNotification.newMessage() Tracker.autorun -> - unreadCount = 0 - subscriptions = ChatSubscription.find({}, { fields: { unread: 1 } }) - (unreadCount += r.unread) for r in subscriptions.fetch() + mentionsCount = 0 + subscriptions = ChatSubscription.find({}, { fields: { mentions: 1 } }) + (mentionsCount += r.mentions) for r in subscriptions.fetch() rxFavico.set 'type', 'warn' - rxFavico.set 'count', unreadCount + rxFavico.set 'count', mentionsCount - if unreadCount > 0 - document.title = '(' + unreadCount + ') Rocket.Chat' + if mentionsCount > 0 + document.title = '(' + mentionsCount + ') Rocket.Chat' else document.title = 'Rocket.Chat' diff --git a/client/stylesheets/base.less b/client/stylesheets/base.less index 55f112263d8b..923fd6e63008 100644 --- a/client/stylesheets/base.less +++ b/client/stylesheets/base.less @@ -1159,7 +1159,7 @@ a.github-fork { } } } - .unread { + .mentions { background-color: #1dce73; min-width: 15px; padding: 0 2px; @@ -1208,7 +1208,11 @@ a.github-fork { background-color: transparent; } } - &.has-unread { + &.has-unread a, &.has-mentions a { + font-weight: bold; + color: #fff; + } + &.has-mentions { .opt { opacity: 0; } diff --git a/client/views/app/sideNav/chatRoomItem.coffee b/client/views/app/sideNav/chatRoomItem.coffee index d87326a7e9e3..f61948f912b3 100644 --- a/client/views/app/sideNav/chatRoomItem.coffee +++ b/client/views/app/sideNav/chatRoomItem.coffee @@ -5,6 +5,12 @@ Template.chatRoomItem.helpers else if Router.current().params._id is this.rid and this.unread > 0 Meteor.call 'readMessages', this.rid + mentions: -> + if (not Router.current().params._id) or Router.current().params._id isnt this.rid + return this.mentions + else if Router.current().params._id is this.rid and this.mentions > 0 + Meteor.call 'readMessages', this.rid + isDirectRoom: -> return this.t is 'd' diff --git a/client/views/app/sideNav/chatRoomItem.html b/client/views/app/sideNav/chatRoomItem.html index 348ef065994b..538820186be0 100644 --- a/client/views/app/sideNav/chatRoomItem.html +++ b/client/views/app/sideNav/chatRoomItem.html @@ -1,8 +1,8 @@