summaryrefslogtreecommitdiffstats
path: root/webapp/actions/post_actions.jsx
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-07-09 06:36:30 +0800
committerGitHub <noreply@github.com>2017-07-09 06:36:30 +0800
commit4956a7198b16630e394e93e69a571df3638f3a99 (patch)
treee8b0832010353aec3744bd04fa99093eb97e42c8 /webapp/actions/post_actions.jsx
parent250a344d04d8e682a98760bdc378d1a5c46f31e6 (diff)
downloadchat-4956a7198b16630e394e93e69a571df3638f3a99.tar.gz
chat-4956a7198b16630e394e93e69a571df3638f3a99.tar.bz2
chat-4956a7198b16630e394e93e69a571df3638f3a99.zip
Revert "PLT-7039 Use loadProfilesAndStatusesForPosts from the redux library (#6881)" (#6882)
This reverts commit 250a344d04d8e682a98760bdc378d1a5c46f31e6.
Diffstat (limited to 'webapp/actions/post_actions.jsx')
-rw-r--r--webapp/actions/post_actions.jsx30
1 files changed, 26 insertions, 4 deletions
diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx
index ae9f069f5..43204a543 100644
--- a/webapp/actions/post_actions.jsx
+++ b/webapp/actions/post_actions.jsx
@@ -19,6 +19,7 @@ import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;
+import {getProfilesByIds} from 'mattermost-redux/actions/users';
import * as PostActions from 'mattermost-redux/actions/posts';
import {getMyChannelMember} from 'mattermost-redux/actions/channels';
@@ -54,7 +55,7 @@ function completePostReceive(post, websocketMessageProps) {
PostActions.getPostThread(post.root_id)(dispatch, getState).then(
(data) => {
dispatchPostActions(post, websocketMessageProps);
- PostActions.getProfilesAndStatusesForPosts(data.posts, dispatch, getState);
+ loadProfilesForPosts(data.posts);
}
);
@@ -122,7 +123,7 @@ export function getFlaggedPosts() {
is_pinned_posts: false
});
- PostActions.getProfilesAndStatusesForPosts(data.posts, dispatch, getState);
+ loadProfilesForPosts(data.posts);
}
).catch(
() => {} //eslint-disable-line no-empty-function
@@ -146,13 +147,34 @@ export function getPinnedPosts(channelId = ChannelStore.getCurrentId()) {
is_pinned_posts: true
});
- PostActions.getProfilesAndStatusesForPosts(data.posts, dispatch, getState);
+ loadProfilesForPosts(data.posts);
}
).catch(
() => {} //eslint-disable-line no-empty-function
);
}
+export function loadProfilesForPosts(posts) {
+ const profilesToLoad = {};
+ for (const pid in posts) {
+ if (!posts.hasOwnProperty(pid)) {
+ continue;
+ }
+
+ const post = posts[pid];
+ if (!UserStore.hasProfile(post.user_id)) {
+ profilesToLoad[post.user_id] = true;
+ }
+ }
+
+ const list = Object.keys(profilesToLoad);
+ if (list.length === 0) {
+ return;
+ }
+
+ getProfilesByIds(list)(dispatch, getState);
+}
+
export function addReaction(channelId, postId, emojiName) {
PostActions.addReaction(postId, emojiName)(dispatch, getState);
}
@@ -230,7 +252,7 @@ export function performSearch(terms, isMentionSearch, success, error) {
is_mention_search: isMentionSearch
});
- PostActions.getProfilesAndStatusesForPosts(data.posts, dispatch, getState);
+ loadProfilesForPosts(data.posts);
if (success) {
success(data);