Save profiles for channel switcher autocomplete to fix switching to new DMs (#4313)
Этот коммит содержится в:
коммит произвёл
enahum
родитель
4834b68ad1
Коммит
3a0b0fe63f
@@ -4,6 +4,7 @@
|
|||||||
import Suggestion from './suggestion.jsx';
|
import Suggestion from './suggestion.jsx';
|
||||||
|
|
||||||
import ChannelStore from 'stores/channel_store.jsx';
|
import ChannelStore from 'stores/channel_store.jsx';
|
||||||
|
import UserStore from 'stores/user_store.jsx';
|
||||||
|
|
||||||
import {autocompleteUsersInTeam} from 'actions/user_actions.jsx';
|
import {autocompleteUsersInTeam} from 'actions/user_actions.jsx';
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ export default class SwitchChannelProvider {
|
|||||||
channelPrefix,
|
channelPrefix,
|
||||||
(data) => {
|
(data) => {
|
||||||
const users = data.in_team;
|
const users = data.in_team;
|
||||||
|
const currentId = UserStore.getCurrentId();
|
||||||
|
|
||||||
for (const id of Object.keys(allChannels)) {
|
for (const id of Object.keys(allChannels)) {
|
||||||
const channel = allChannels[id];
|
const channel = allChannels[id];
|
||||||
@@ -75,14 +77,21 @@ export default class SwitchChannelProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const userMap = {};
|
||||||
for (let i = 0; i < users.length; i++) {
|
for (let i = 0; i < users.length; i++) {
|
||||||
const user = users[i];
|
const user = users[i];
|
||||||
|
|
||||||
|
if (user.id === currentId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const newChannel = {
|
const newChannel = {
|
||||||
display_name: user.username,
|
display_name: user.username,
|
||||||
name: user.username + ' ' + Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)'),
|
name: user.username + ' ' + Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)'),
|
||||||
type: Constants.DM_CHANNEL
|
type: Constants.DM_CHANNEL
|
||||||
};
|
};
|
||||||
channels.push(newChannel);
|
channels.push(newChannel);
|
||||||
|
userMap[user.id] = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
channels.sort((a, b) => {
|
channels.sort((a, b) => {
|
||||||
@@ -107,6 +116,11 @@ export default class SwitchChannelProvider {
|
|||||||
items: channels,
|
items: channels,
|
||||||
component: SwitchChannelSuggestion
|
component: SwitchChannelSuggestion
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AppDispatcher.handleServerAction({
|
||||||
|
type: ActionTypes.RECEIVED_PROFILES,
|
||||||
|
profiles: userMap
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user