From 9b9facd3d21a7ab341dd6d80fd8b53fb852ae036 Mon Sep 17 00:00:00 2001
From: samogot <samogot@gmail.com>
Date: Thu, 14 Jul 2016 15:19:27 +0300
Subject: PLT-3366 Holding down the ALT key and clicking on a message adds a
 new messages indicator (squashed) (#3374)

---
 webapp/utils/async_client.jsx | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

(limited to 'webapp/utils/async_client.jsx')

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;
-- 
cgit v1.2.3-1-g7c22

