summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-08-18 09:19:29 -0400
committerChristopher Speller <crspeller@gmail.com>2015-08-18 09:19:29 -0400
commit532be141bae8ff2ea03de4fa54affd6e72dab9ea (patch)
treefb0f76405960217477f4f91212da395543b84657 /web/react/utils
parent4805608cc9cf79277f37b94bbe38398816469884 (diff)
parentf4c2a9244c72786cc9a90597d9cb373e0cfee4c7 (diff)
downloadchat-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')
-rw-r--r--web/react/utils/async_client.jsx27
-rw-r--r--web/react/utils/constants.jsx3
2 files changed, 21 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;
}
);
}
diff --git a/web/react/utils/constants.jsx b/web/react/utils/constants.jsx
index 1fe0faccf..41b02c8d6 100644
--- a/web/react/utils/constants.jsx
+++ b/web/react/utils/constants.jsx
@@ -15,6 +15,7 @@ module.exports = {
RECIEVED_CHANNEL_EXTRA_INFO: null,
RECIEVED_POSTS: null,
+ RECIEVED_POST: null,
RECIEVED_SEARCH: null,
RECIEVED_POST_SELECTED: null,
RECIEVED_MENTION_DATA: null,
@@ -62,6 +63,8 @@ module.exports = {
GOOGLE_SERVICE: 'google',
POST_CHUNK_SIZE: 60,
MAX_POST_CHUNKS: 3,
+ POST_LOADING: "loading",
+ POST_FAILED: "failed",
RESERVED_TEAM_NAMES: [
"www",
"web",