PLT-6202 Make DM's and GM's visible if necessary (#457)

This commit is contained in:
enahum 2017-04-05 22:33:13 -03:00 committed by GitHub
parent 007c8bcf35
commit 491fba7738

View file

@ -15,15 +15,23 @@ import {
} from 'mattermost-redux/actions/channels';
import {getPosts, getPostsSince} from 'mattermost-redux/actions/posts';
import {getFilesForPost} from 'mattermost-redux/actions/files';
import {savePreferences, deletePreferences} from 'mattermost-redux/actions/preferences';
import {
makeDirectChannelVisibleIfNecessary,
makeGroupMessageVisibleIfNecessary,
savePreferences,
deletePreferences
} from 'mattermost-redux/actions/preferences';
import {getTeamMembersByIds} from 'mattermost-redux/actions/teams';
import {getProfilesInChannel} from 'mattermost-redux/actions/users';
import {Constants, Preferences, UsersTypes} from 'mattermost-redux/constants';
import {
getChannelByName,
getDirectChannelName,
getUserIdFromChannelName,
isDirectChannelVisible,
isGroupChannelVisible
isGroupChannelVisible,
isDirectChannel,
isGroupChannel
} from 'mattermost-redux/utils/channel_utils';
import {getPreferencesByCategory} from 'mattermost-redux/utils/preference_utils';
@ -60,6 +68,17 @@ export function loadProfilesAndTeamMembersForDMSidebar(teamId) {
const members = [];
const loadProfilesForChannels = [];
// Find DM's and GM's that need to be shown
const directChannels = Object.values(channels).filter((c) => (isDirectChannel(c) || isGroupChannel(c)));
directChannels.forEach((channel) => {
if (isDirectChannel(channel)) {
const teammateId = getUserIdFromChannelName(currentUserId, channel.name);
makeDirectChannelVisibleIfNecessary(teammateId)(dispatch, getState);
} else if (isGroupChannel(channel)) {
makeGroupMessageVisibleIfNecessary(channel.id)(dispatch, getState);
}
});
for (const [key, pref] of dmPrefs) {
if (pref.value === 'true') {
members.push(key);