summaryrefslogtreecommitdiffstats
path: root/webapp/actions/user_actions.jsx
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-05-01 10:49:34 -0400
committerGitHub <noreply@github.com>2017-05-01 10:49:34 -0400
commit2d22fb5652e547b4fe169dee2ea9cd14f747a485 (patch)
treea27e0a814ca2563ca9d20970201e397aa88afc6f /webapp/actions/user_actions.jsx
parent83f819451a80a767170b927eb2f0d5ed63f03239 (diff)
downloadchat-2d22fb5652e547b4fe169dee2ea9cd14f747a485.tar.gz
chat-2d22fb5652e547b4fe169dee2ea9cd14f747a485.tar.bz2
chat-2d22fb5652e547b4fe169dee2ea9cd14f747a485.zip
Prevent unnecessary store emits (#6285)
* Remove unnecessary store emits * Drastically reduce number of emitted changes
Diffstat (limited to 'webapp/actions/user_actions.jsx')
-rw-r--r--webapp/actions/user_actions.jsx5
1 files changed, 4 insertions, 1 deletions
diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx
index eacb0df80..8dfc819b9 100644
--- a/webapp/actions/user_actions.jsx
+++ b/webapp/actions/user_actions.jsx
@@ -24,6 +24,8 @@ import store from 'stores/redux_store.jsx';
const dispatch = store.dispatch;
const getState = store.getState;
+import * as Selectors from 'mattermost-redux/selectors/entities/users';
+
import {
getProfiles,
getProfilesInChannel,
@@ -239,7 +241,8 @@ function populateDMChannelsWithProfiles(userIds) {
for (let i = 0; i < userIds.length; i++) {
const channelName = getDirectChannelName(currentUserId, userIds[i]);
const channel = ChannelStore.getByName(channelName);
- if (channel) {
+ const profilesInChannel = Selectors.getUserIdsInChannels(getState())[channel.id] || new Set();
+ if (channel && !profilesInChannel.has(userIds[i])) {
UserStore.saveUserIdInChannel(channel.id, userIds[i]);
}
}