Improve perf for channel switching, fix team switching issues (#6286)
* Improve perf for channel switching, fix team switching issues * Fix last channel when switching teams
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
294bd08255
Коммит
042052aec6
@@ -25,7 +25,7 @@ import store from 'stores/redux_store.jsx';
|
|||||||
const dispatch = store.dispatch;
|
const dispatch = store.dispatch;
|
||||||
const getState = store.getState;
|
const getState = store.getState;
|
||||||
import {getProfilesByIds} from 'mattermost-redux/actions/users';
|
import {getProfilesByIds} from 'mattermost-redux/actions/users';
|
||||||
import {getChannelMember} from 'mattermost-redux/actions/channels';
|
import {getMyChannelMember} from 'mattermost-redux/actions/channels';
|
||||||
|
|
||||||
export function handleNewPost(post, msg) {
|
export function handleNewPost(post, msg) {
|
||||||
let websocketMessageProps = {};
|
let websocketMessageProps = {};
|
||||||
@@ -41,7 +41,7 @@ export function handleNewPost(post, msg) {
|
|||||||
Client.setTeamId(msg.data.team_id);
|
Client.setTeamId(msg.data.team_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
getChannelMember(post.channel_id, UserStore.getCurrentId())(dispatch, getState).then(() => completePostReceive(post, websocketMessageProps));
|
getMyChannelMember(post.channel_id)(dispatch, getState).then(() => completePostReceive(post, websocketMessageProps));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg && msg.data) {
|
if (msg && msg.data) {
|
||||||
|
|||||||
@@ -116,14 +116,19 @@ export default class Sidebar extends React.Component {
|
|||||||
const currentChannelId = ChannelStore.getCurrentId();
|
const currentChannelId = ChannelStore.getCurrentId();
|
||||||
const tutorialStep = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 999);
|
const tutorialStep = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 999);
|
||||||
|
|
||||||
const allChannels = ChannelStore.getAll().map((channel) => Object.assign({}, channel));
|
const channels = ChannelStore.getAll();
|
||||||
const channelList = ChannelUtils.buildDisplayableChannelList(allChannels);
|
let displayableChannels = {};
|
||||||
|
if (channels !== this.oldChannels) {
|
||||||
|
const channelsArray = channels.map((channel) => Object.assign({}, channel));
|
||||||
|
displayableChannels = ChannelUtils.buildDisplayableChannelList(channelsArray);
|
||||||
|
}
|
||||||
|
this.oldChannels = channels;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeId: currentChannelId,
|
activeId: currentChannelId,
|
||||||
members,
|
members,
|
||||||
teamMembers,
|
teamMembers,
|
||||||
...channelList,
|
...displayableChannels,
|
||||||
unreadCounts: JSON.parse(JSON.stringify(ChannelStore.getUnreadCounts())),
|
unreadCounts: JSON.parse(JSON.stringify(ChannelStore.getUnreadCounts())),
|
||||||
showTutorialTip: tutorialStep === TutorialSteps.CHANNEL_POPOVER,
|
showTutorialTip: tutorialStep === TutorialSteps.CHANNEL_POPOVER,
|
||||||
currentTeam: TeamStore.getCurrent(),
|
currentTeam: TeamStore.getCurrent(),
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ class ChannelStoreClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getChannelById(id) {
|
getChannelById(id) {
|
||||||
return Selectors.getChannelsInCurrentTeam(store.getState())[id];
|
return this.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
storeMyChannelMember(channelMember) {
|
storeMyChannelMember(channelMember) {
|
||||||
|
|||||||
@@ -342,20 +342,6 @@ class TeamStoreClass extends EventEmitter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUnreadCount(teamId, totalMsgCount, channelMember) {
|
|
||||||
let member = this.getMyTeamMembers().filter((m) => m.team_id === teamId)[0];
|
|
||||||
if (member) {
|
|
||||||
member = Object.assign({}, member);
|
|
||||||
member.msg_count -= (totalMsgCount - channelMember.msg_count);
|
|
||||||
member.mention_count -= channelMember.mention_count;
|
|
||||||
|
|
||||||
store.dispatch({
|
|
||||||
type: TeamTypes.RECEIVED_MY_TEAM_MEMBER,
|
|
||||||
data: member
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
subtractUnread(teamId, msgs, mentions) {
|
subtractUnread(teamId, msgs, mentions) {
|
||||||
let member = this.getMyTeamMembers().filter((m) => m.team_id === teamId)[0];
|
let member = this.getMyTeamMembers().filter((m) => m.team_id === teamId)[0];
|
||||||
if (member) {
|
if (member) {
|
||||||
@@ -443,11 +429,6 @@ TeamStore.dispatchToken = AppDispatcher.register((payload) => {
|
|||||||
case ActionTypes.RECEIVED_TEAM_STATS:
|
case ActionTypes.RECEIVED_TEAM_STATS:
|
||||||
TeamStore.saveStats(action.team_id, action.stats);
|
TeamStore.saveStats(action.team_id, action.stats);
|
||||||
break;
|
break;
|
||||||
case ActionTypes.CLICK_CHANNEL:
|
|
||||||
if (action.channelMember) {
|
|
||||||
TeamStore.updateUnreadCount(action.team_id, action.total_msg_count, action.channelMember);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ActionTypes.RECEIVED_POST:
|
case ActionTypes.RECEIVED_POST:
|
||||||
if (action.post.type === PostTypes.JOIN_LEAVE || action.post.type === PostTypes.JOIN_CHANNEL || action.post.type === PostTypes.LEAVE_CHANNEL) {
|
if (action.post.type === PostTypes.JOIN_LEAVE || action.post.type === PostTypes.JOIN_CHANNEL || action.post.type === PostTypes.LEAVE_CHANNEL) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user