From effd0840231474cc0f967f51fcec3780369ed916 Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Fri, 2 Sep 2016 11:21:10 -0400
Subject: Show loading icon until first page of posts is loaded on channel
 switch (#3918)

---
 webapp/utils/async_client.jsx | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

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

diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx
index 74064169f..729160fe4 100644
--- a/webapp/utils/async_client.jsx
+++ b/webapp/utils/async_client.jsx
@@ -609,14 +609,13 @@ export function getPosts(id) {
     }
 
     const postList = PostStore.getAllPosts(channelId);
+    const latestPostTime = PostStore.getLatestPostFromPageTime(id);
 
-    if ($.isEmptyObject(postList) || postList.order.length < Constants.POST_CHUNK_SIZE) {
+    if ($.isEmptyObject(postList) || postList.order.length < Constants.POST_CHUNK_SIZE || latestPostTime === 0) {
         getPostsPage(channelId, Constants.POST_CHUNK_SIZE);
         return;
     }
 
-    const latestPostTime = PostStore.getLatestPostFromPageTime(id);
-
     callTracker['getPosts_' + channelId] = utils.getTimestamp();
 
     Client.getPosts(
-- 
cgit v1.2.3-1-g7c22

