Commit 27d34668 authored by Sudheer's avatar Sudheer Committed by Carlos Tadeu Panato Junior

MM-11717 Exclude deleted users from favorites list (#618)

parent a71036a9
......@@ -549,6 +549,11 @@ export const getSortedFavoriteChannelWithUnreadsIds = createIdsSelector(
return false;
}
// Deleted users from CLI will not have a profiles entry
if (channel.type === General.DM_CHANNEL && !profiles[otherUserId]) {
return false;
}
if (channel.type === General.DM_CHANNEL && !isDirectChannelVisible(profiles[otherUserId] || otherUserId, config, prefs, channel, null, null, currentChannelId)) {
return false;
} else if (channel.type === General.GM_CHANNEL && !isGroupChannelVisible(config, prefs, channel)) {
......
......@@ -744,5 +744,57 @@ describe('Selectors.Channels', () => {
{...channel13, display_name: profiles.fakeUserId.username},
]);
});
it('Should not include deleted users in favorites', () => {
const newDmChannel = TestHelper.fakeDmChannel(user.id, 'newfakeId');
newDmChannel.total_msg_count = 1;
newDmChannel.display_name = '';
newDmChannel.name = getDirectChannelName(user.id, 'newfakeId');
const newState = {
...testState,
entities: {
...testState.entities,
channels: {
...testState.entities.channels,
channels: {
...testState.entities.channels.channels,
[newDmChannel.id]: newDmChannel,
},
channelsInTeam: {
...testState.entities.channels.channelsInTeam,
'': [
...testState.entities.channels.channelsInTeam[''],
newDmChannel.id,
],
},
myMembers: {
...testState.entities.channels.myMembers,
[newDmChannel.id]: {channel_id: newDmChannel.id, user_id: user.id, msg_count: 1, mention_count: 0, notifyProps: {}},
},
},
preferences: {
myPreferences: {
...testState.entities.preferences.myPreferences,
[`${Preferences.CATEGORY_FAVORITE_CHANNEL}--${newDmChannel.id}`]: {
name: newDmChannel.id,
category: Preferences.CATEGORY_FAVORITE_CHANNEL,
value: 'true',
},
[`${Preferences.CATEGORY_DIRECT_CHANNEL_SHOW}--newfakeId`]: {
category: Preferences.CATEGORY_DIRECT_CHANNEL_SHOW,
name: 'newfakeId',
value: 'true',
},
},
},
},
};
const fromOriginalState = Selectors.getSortedFavoriteChannelWithUnreadsIds(testState);
const fromModifiedState = Selectors.getSortedFavoriteChannelWithUnreadsIds(newState);
assert.ok(fromOriginalState.length === 2);
assert.ok(fromModifiedState.length === 2);
});
});
});
......@@ -237,6 +237,7 @@ class TestHelper {
status: 'offline',
teammate_id: `${otherUserId}`,
id: this.generateId(),
delete_at: 0,
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment