diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-08-18 09:19:29 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-08-18 09:19:29 -0400 |
commit | 532be141bae8ff2ea03de4fa54affd6e72dab9ea (patch) | |
tree | fb0f76405960217477f4f91212da395543b84657 /web/react/utils/async_client.jsx | |
parent | 4805608cc9cf79277f37b94bbe38398816469884 (diff) | |
parent | f4c2a9244c72786cc9a90597d9cb373e0cfee4c7 (diff) | |
download | chat-532be141bae8ff2ea03de4fa54affd6e72dab9ea.tar.gz chat-532be141bae8ff2ea03de4fa54affd6e72dab9ea.tar.bz2 chat-532be141bae8ff2ea03de4fa54affd6e72dab9ea.zip |
Merge pull request #380 from mattermost/mm-319
MM-319 adding pending post functionality to the client
Diffstat (limited to 'web/react/utils/async_client.jsx')
-rw-r--r-- | web/react/utils/async_client.jsx | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index 8b6d821d6..349fe9021 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -346,24 +346,33 @@ module.exports.search = function(terms) { module.exports.getPosts = function(force, id, maxPosts) { if (PostStore.getCurrentPosts() == null || force) { - var channelId = id ? id : ChannelStore.getCurrentId(); + var channelId = id; + if (channelId == null) { + channelId = ChannelStore.getCurrentId(); + } - if (isCallInProgress('getPosts_'+channelId)) return; + if (isCallInProgress('getPosts_' + channelId)) { + return; + } - var post_list = PostStore.getCurrentPosts(); + var postList = PostStore.getCurrentPosts(); - if (!maxPosts) { maxPosts = Constants.POST_CHUNK_SIZE * Constants.MAX_POST_CHUNKS }; + var max = maxPosts; + if (max == null) { + max = Constants.POST_CHUNK_SIZE * Constants.MAX_POST_CHUNKS; + } // if we already have more than POST_CHUNK_SIZE posts, // let's get the amount we have but rounded up to next multiple of POST_CHUNK_SIZE, // with a max at maxPosts - var numPosts = Math.min(maxPosts, Constants.POST_CHUNK_SIZE); - if (post_list && post_list.order.length > 0) { - numPosts = Math.min(maxPosts, Constants.POST_CHUNK_SIZE * Math.ceil(post_list.order.length / Constants.POST_CHUNK_SIZE)); + var numPosts = Math.min(max, Constants.POST_CHUNK_SIZE); + if (postList && postList.order.length > 0) { + numPosts = Math.min(max, Constants.POST_CHUNK_SIZE * Math.ceil(postList.order.length / Constants.POST_CHUNK_SIZE)); } if (channelId != null) { - callTracker['getPosts_'+channelId] = utils.getTimestamp(); + callTracker['getPosts_' + channelId] = utils.getTimestamp(); + client.getPosts( channelId, 0, @@ -383,7 +392,7 @@ module.exports.getPosts = function(force, id, maxPosts) { dispatchError(err, 'getPosts'); }, function() { - callTracker['getPosts_'+channelId] = 0; + callTracker['getPosts_' + channelId] = 0; } ); } |