-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
channel.js
39 lines (32 loc) · 1.04 KB
/
channel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {createSelector} from 'reselect';
import {getCurrentUserId, getUser} from 'mattermost-redux/selectors/entities/users';
const getOtherUserIdForDm = createSelector(
(state, channel) => channel,
getCurrentUserId,
(channel, currentUserId) => {
if (!channel) {
return '';
}
return channel.name.split('__').find((m) => m !== currentUserId) || currentUserId;
}
);
export const getChannelMembersForDm = createSelector(
(state, channel) => getUser(state, getOtherUserIdForDm(state, channel)),
(otherUser) => {
if (!otherUser) {
return [];
}
return [otherUser];
}
);
export const getChannelNameForSearchAutocomplete = createSelector(
(state, channelId) => state.entities.channels.channels[channelId],
(channel) => {
if (channel && channel.display_name) {
return channel.display_name;
}
return '';
}
);