Improve unread a little bit

pull/2652/merge
Rodrigo Nascimento 9 years ago
parent 286e3b713b
commit 24ab931cca
  1. 4
      client/startup/unread.coffee
  2. 22
      packages/rocketchat-ui/views/app/room.coffee
  3. 38
      packages/rocketchat-ui/views/app/room.html

@ -21,7 +21,9 @@ Meteor.startup ->
if hasFocus and subscriptionIsTheOpenedRoom
# The user has probably read all messages in this room.
# TODO: readNow() should return whether it has actually marked the room as read.
readMessage.readNow()
Meteor.setTimeout ->
readMessage.readNow()
, 500
# Increment the total unread count.
unreadCount += subscription.unread

@ -164,21 +164,20 @@ Template.room.helpers
wavEnabled = !RocketChat.settings.get("FileUpload_MediaTypeWhiteList") || RocketChat.settings.get("FileUpload_MediaTypeWhiteList").match(wavRegex)
return RocketChat.settings.get('Message_AudioRecorderEnabled') and (navigator.getUserMedia? or navigator.webkitGetUserMedia?) and wavEnabled and RocketChat.settings.get('FileUpload_Enabled')
unreadSince: ->
room = ChatRoom.findOne(this._id, { reactive: false })
unreadData: ->
data =
count: RoomHistoryManager.getRoom(this._id).unreadNotLoaded.get() + Template.instance().unreadCount.get()
room = RoomManager.getOpenedRoomByRid this._id
if room?
return RoomManager.openedRooms[room.t + room.name]?.unreadSince?.get()
data.since = room.unreadSince?.get()
unreadCount: ->
return RoomHistoryManager.getRoom(@_id).unreadNotLoaded.get() + Template.instance().unreadCount.get()
return data
formatUnreadSince: ->
room = ChatRoom.findOne(this._id, { reactive: false })
room = RoomManager.openedRooms[room?.t + room?.name]
date = room?.unreadSince.get()
if not date? then return
if not this.since? then return
return moment(date).calendar(null, {sameDay: 'LT'})
return moment(this.since).calendar(null, {sameDay: 'LT'})
flexTemplate: ->
return RocketChat.TabBar.getTemplate()
@ -588,7 +587,8 @@ Template.room.onRendered ->
firstMessage = ChatMessage.findOne firstMessageOnScreen.id
if firstMessage?
subscription = ChatSubscription.findOne rid: template.data._id
template.unreadCount.set ChatMessage.find({rid: template.data._id, ts: {$lt: firstMessage.ts, $gt: subscription?.ls}}).count()
count = ChatMessage.find({rid: template.data._id, ts: {$lt: firstMessage.ts, $gt: subscription?.ls}}).count()
template.unreadCount.set count
else
template.unreadCount.set 0
, 300

@ -18,25 +18,27 @@
</h2>
</header>
<div class="container-bars">
{{#if unreadCount}}
{{#if unreadSince}}
<div class="unread-bar">
<a class="jump-to">
<span class="jump-to-large">{{_ "Jump_to_first_unread"}}</span>
<span class="jump-to-small">{{_ "Jump"}}</span>
</a>
<span class="unread-count-since">
{{_ "S_new_messages_since_s" unreadCount formatUnreadSince}}
</span>
<span class="unread-count">
{{_ "N_new_messages" unreadCount}}
</span>
<a class="mark-read">
{{_ "Mark_as_read"}}
</a>
</div>
{{#with unreadData}}
{{#if since}}
{{#if count}}
<div class="unread-bar">
<a class="jump-to">
<span class="jump-to-large">{{_ "Jump_to_first_unread"}}</span>
<span class="jump-to-small">{{_ "Jump"}}</span>
</a>
<span class="unread-count-since">
{{_ "S_new_messages_since_s" count formatUnreadSince}}
</span>
<span class="unread-count">
{{_ "N_new_messages" count}}
</span>
<a class="mark-read">
{{_ "Mark_as_read"}}
</a>
</div>
{{/if}}
{{/if}}
{{/if}}
{{/with}}
{{#each uploading}}
<div class="upload-progress {{#if error}}upload-error{{/if}}">
{{#if error}}

Loading…
Cancel
Save