diff options
author | =Corey Hulen <corey@hulen.com> | 2015-08-02 09:41:12 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-08-02 09:41:12 -0800 |
commit | 247708d924770737a3c03f956b19d8096da2bdea (patch) | |
tree | 3d6bd381545e660808f74a1379048e57cc0c6717 /web/react/utils/async_client.jsx | |
parent | e76fc37b6df7d53ea86a5b42009d5d1161741270 (diff) | |
parent | 718d670d699e295fcad903d507bc989c51a1ef50 (diff) | |
download | chat-247708d924770737a3c03f956b19d8096da2bdea.tar.gz chat-247708d924770737a3c03f956b19d8096da2bdea.tar.bz2 chat-247708d924770737a3c03f956b19d8096da2bdea.zip |
Merge branch 'master' into mm-1619
Diffstat (limited to 'web/react/utils/async_client.jsx')
-rw-r--r-- | web/react/utils/async_client.jsx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx index 00bd83ed1..dc4fc1096 100644 --- a/web/react/utils/async_client.jsx +++ b/web/react/utils/async_client.jsx @@ -272,17 +272,23 @@ module.exports.search = function(terms) { ); } -module.exports.getPosts = function(force, id) { +module.exports.getPosts = function(force, id, maxPosts) { if (PostStore.getCurrentPosts() == null || force) { var channelId = id ? id : ChannelStore.getCurrentId(); if (isCallInProgress("getPosts_"+channelId)) return; var post_list = PostStore.getCurrentPosts(); + + if (!maxPosts) { maxPosts = 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 180 - var numPosts = post_list && post_list.order.length > 0 ? Math.min(180, Constants.POST_CHUNK_SIZE * Math.ceil(post_list.order.length / Constants.POST_CHUNK_SIZE)) : Constants.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)); + } if (channelId != null) { callTracker["getPosts_"+channelId] = utils.getTimestamp(); |