diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-09-02 12:50:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-02 12:50:15 -0400 |
commit | f32eb525f3fa0828a23f589d765c267e3b2aea86 (patch) | |
tree | d4b76aecf89143029af080b3e1b4d87398e0adc5 /webapp/utils/async_client.jsx | |
parent | eb0111f6bbe2b0bf160a674dfe1b4d089f905cb9 (diff) | |
download | chat-f32eb525f3fa0828a23f589d765c267e3b2aea86.tar.gz chat-f32eb525f3fa0828a23f589d765c267e3b2aea86.tar.bz2 chat-f32eb525f3fa0828a23f589d765c267e3b2aea86.zip |
Do not send push notifications for channels being actively viewed (#3931)
Diffstat (limited to 'webapp/utils/async_client.jsx')
-rw-r--r-- | webapp/utils/async_client.jsx | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx index 729160fe4..585e4b1c0 100644 --- a/webapp/utils/async_client.jsx +++ b/webapp/utils/async_client.jsx @@ -113,7 +113,7 @@ export function getChannel(id) { ); } -export function updateLastViewedAt(id) { +export function updateLastViewedAt(id, active) { let channelId; if (id) { channelId = id; @@ -129,9 +129,17 @@ export function updateLastViewedAt(id) { return; } + let isActive; + if (active == null) { + isActive = true; + } else { + isActive = active; + } + callTracker[`updateLastViewed${channelId}`] = utils.getTimestamp(); Client.updateLastViewedAt( channelId, + isActive, () => { callTracker[`updateLastViewed${channelId}`] = 0; ErrorStore.clearLastError(); @@ -753,6 +761,24 @@ export function getStatuses() { ); } +export function setActiveChannel(channelId) { + if (isCallInProgress(`setActiveChannel${channelId}`)) { + return; + } + + callTracker[`setActiveChannel${channelId}`] = utils.getTimestamp(); + Client.setActiveChannel( + channelId, + () => { + callTracker[`setActiveChannel${channelId}`] = 0; + }, + (err) => { + callTracker[`setActiveChannel${channelId}`] = 0; + dispatchError(err, 'setActiveChannel'); + } + ); +} + export function getMyTeam() { if (isCallInProgress('getMyTeam')) { return null; |