summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/async_client.jsx12
-rw-r--r--web/react/utils/constants.jsx1
-rw-r--r--web/react/utils/utils.jsx2
3 files changed, 11 insertions, 4 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();
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index 3509c9514..c51007a66 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -57,6 +57,7 @@ module.exports = {
DEFAULT_CHANNEL: 'town-square',
OFFTOPIC_CHANNEL: 'off-topic',
POST_CHUNK_SIZE: 60,
+ MAX_POST_CHUNKS: 3,
RESERVED_TEAM_NAMES: [
"www",
"web",
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 09240bf06..a759cc579 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -750,7 +750,7 @@ module.exports.switchChannel = function(channel, teammate_name) {
AsyncClient.getChannels(true, true, true);
AsyncClient.getChannelExtraInfo(true);
- AsyncClient.getPosts(true, channel.id);
+ AsyncClient.getPosts(true, channel.id, Constants.POST_CHUNK_SIZE);
$('.inner__wrap').removeClass('move--right');
$('.sidebar--left').removeClass('move--right');