diff options
author | Pierre Rudloff <contact@rudloff.pro> | 2017-02-07 16:15:02 +0100 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-02-07 07:15:02 -0800 |
commit | 466bd8415d1ff9fed0cd5b263d0eed35c87b7e2b (patch) | |
tree | 6a681cfe01dba928ef73b9496c03872a10a64847 /webapp | |
parent | 0dae6d015aed1d9034600210ed8efe55a340b0ac (diff) | |
download | chat-466bd8415d1ff9fed0cd5b263d0eed35c87b7e2b.tar.gz chat-466bd8415d1ff9fed0cd5b263d0eed35c87b7e2b.tar.bz2 chat-466bd8415d1ff9fed0cd5b263d0eed35c87b7e2b.zip |
Add a notification for new messages on mobile (#5179) (#5234)
Diffstat (limited to 'webapp')
-rw-r--r-- | webapp/components/notify_counts.jsx | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/webapp/components/notify_counts.jsx b/webapp/components/notify_counts.jsx index 55ede2d90..fe40fd485 100644 --- a/webapp/components/notify_counts.jsx +++ b/webapp/components/notify_counts.jsx @@ -6,14 +6,16 @@ import ChannelStore from 'stores/channel_store.jsx'; import TeamStore from 'stores/team_store.jsx'; function getCountsStateFromStores() { - let count = 0; + let mentionCount = 0; + let messageCount = 0; const teamMembers = TeamStore.getMyTeamMembers(); const channels = ChannelStore.getAll(); const members = ChannelStore.getMyMembers(); teamMembers.forEach((member) => { if (member.team_id !== TeamStore.getCurrentId()) { - count += (member.mention_count || 0); + mentionCount += (member.mention_count || 0); + messageCount += (member.msg_count || 0); } }); @@ -24,13 +26,16 @@ function getCountsStateFromStores() { } if (channel.type === 'D') { - count += channel.total_msg_count - channelMember.msg_count; + mentionCount += channel.total_msg_count - channelMember.msg_count; } else if (channelMember.mention_count > 0) { - count += channelMember.mention_count; + mentionCount += channelMember.mention_count; + } + if (channelMember.notify_props.mark_unread !== 'mention' && channel.total_msg_count - channelMember.msg_count > 0) { + messageCount += 1; } }); - return {count}; + return {mentionCount, messageCount}; } import React from 'react'; @@ -63,8 +68,10 @@ export default class NotifyCounts extends React.Component { } } render() { - if (this.state.count) { - return <span className='badge badge-notify'>{this.state.count}</span>; + if (this.state.mentionCount) { + return <span className='badge badge-notify'>{this.state.mentionCount}</span>; + } else if (this.state.messageCount) { + return <span className='badge badge-notify'>{'•'}</span>; } return null; } |