diff options
Diffstat (limited to 'webapp/utils/async_client.jsx')
-rw-r--r-- | webapp/utils/async_client.jsx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx index e55742140..2e26278b2 100644 --- a/webapp/utils/async_client.jsx +++ b/webapp/utils/async_client.jsx @@ -145,6 +145,43 @@ export function updateLastViewedAt(id) { ); } +export function setLastViewedAt(lastViewedAt, id) { + let channelId; + if (id) { + channelId = id; + } else { + channelId = ChannelStore.getCurrentId(); + } + + if (channelId == null) { + return; + } + + if (lastViewedAt == null) { + return; + } + + if (isCallInProgress(`setLastViewedAt${channelId}${lastViewedAt}`)) { + return; + } + + callTracker[`setLastViewedAt${channelId}${lastViewedAt}`] = utils.getTimestamp(); + Client.setLastViewedAt( + channelId, + lastViewedAt, + () => { + callTracker.setLastViewedAt = 0; + ErrorStore.clearLastError(); + }, + (err) => { + callTracker.setLastViewedAt = 0; + var count = ErrorStore.getConnectionErrorCount(); + ErrorStore.setConnectionErrorCount(count + 1); + dispatchError(err, 'setLastViewedAt'); + } + ); +} + export function getMoreChannels(force) { if (isCallInProgress('getMoreChannels')) { return; |