From db7540b111f8b9f983adcfc73fd897e5d83c2fef Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Wed, 8 Mar 2017 04:13:16 -0500
Subject: Add sync logic for DMs/GMs when network reconnects (#5676)

---
 webapp/utils/async_client.jsx | 41 +++++++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 18 deletions(-)

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

diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx
index e1449e3c5..9ba853238 100644
--- a/webapp/utils/async_client.jsx
+++ b/webapp/utils/async_client.jsx
@@ -64,26 +64,31 @@ export function checkVersion() {
 }
 
 export function getChannels() {
-    if (isCallInProgress('getChannels')) {
-        return null;
-    }
+    return new Promise((resolve, reject) => {
+        if (isCallInProgress('getChannels')) {
+            resolve();
+            return;
+        }
 
-    callTracker.getChannels = utils.getTimestamp();
+        callTracker.getChannels = utils.getTimestamp();
 
-    return Client.getChannels(
-        (data) => {
-            callTracker.getChannels = 0;
+        Client.getChannels(
+            (data) => {
+                callTracker.getChannels = 0;
 
-            AppDispatcher.handleServerAction({
-                type: ActionTypes.RECEIVED_CHANNELS,
-                channels: data
-            });
-        },
-        (err) => {
-            callTracker.getChannels = 0;
-            dispatchError(err, 'getChannels');
-        }
-    );
+                AppDispatcher.handleServerAction({
+                    type: ActionTypes.RECEIVED_CHANNELS,
+                    channels: data
+                });
+                resolve();
+            },
+            (err) => {
+                callTracker.getChannels = 0;
+                dispatchError(err, 'getChannels');
+                reject();
+            }
+        );
+    });
 }
 
 export function getChannel(id) {
@@ -130,7 +135,7 @@ export function getMyChannelMembers() {
                 resolve();
             },
             (err) => {
-                callTracker.getChannelsUnread = 0;
+                callTracker.getMyChannelMembers = 0;
                 dispatchError(err, 'getMyChannelMembers');
                 reject();
             }
-- 
cgit v1.2.3-1-g7c22

