Skip to content

Commit

Permalink
PLT-5140: Display loading screen when switching team (#5475)
Browse files Browse the repository at this point in the history
* fix: clear channel list on team change

* fix committed config

* fix: no need to use anothe var

* fix: better channel list clearing

* remove unused function

* fix: display loading screen when switching team

* fix: display loading screen when switching team

* fix: clear channel list on team change

* fix committed config

* fix: no need to use anothe var

* fix: better channel list clearing

* remove unused function

* remove duplicate EnableUserTypingMessages
  • Loading branch information
mikaoelitiana authored and enahum committed Feb 26, 2017
1 parent 97cc0a0 commit 04f4545
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions webapp/components/post_view/post_view_controller.jsx
Expand Up @@ -8,6 +8,7 @@ import PreferenceStore from 'stores/preference_store.jsx';
import UserStore from 'stores/user_store.jsx';
import PostStore from 'stores/post_store.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import TeamStore from 'stores/team_store.jsx';
import WebrtcStore from 'stores/webrtc_store.jsx';

import * as Utils from 'utils/utils.jsx';
Expand All @@ -25,6 +26,7 @@ export default class PostViewController extends React.Component {
this.onPreferenceChange = this.onPreferenceChange.bind(this);
this.onUserChange = this.onUserChange.bind(this);
this.onPostsChange = this.onPostsChange.bind(this);
this.onTeamChange = this.onTeamChange.bind(this);
this.onStatusChange = this.onStatusChange.bind(this);
this.onPostsViewJumpRequest = this.onPostsViewJumpRequest.bind(this);
this.onSetNewMessageIndicator = this.onSetNewMessageIndicator.bind(this);
Expand Down Expand Up @@ -55,6 +57,7 @@ export default class PostViewController extends React.Component {
channel,
postList: PostStore.filterPosts(channel.id, joinLeaveEnabled),
currentUser: UserStore.getCurrentUser(),
currentTeamId: TeamStore.getCurrentId(),
isBusy: WebrtcStore.isBusy(),
profiles,
statuses,
Expand Down Expand Up @@ -131,9 +134,20 @@ export default class PostViewController extends React.Component {
this.setState({statuses: Object.assign({}, UserStore.getStatuses())});
}

onTeamChange() {
const currentTeamId = TeamStore.getCurrentId();
if (this.state.channel.team_id !== currentTeamId) {
this.setState({
currentTeamId,
loading: true
});
}
}

onActivate() {
PreferenceStore.addChangeListener(this.onPreferenceChange);
UserStore.addChangeListener(this.onUserChange);
TeamStore.addChangeListener(this.onTeamChange);
UserStore.addStatusesChangeListener(this.onStatusChange);
PostStore.addChangeListener(this.onPostsChange);
PostStore.addPostsViewJumpListener(this.onPostsViewJumpRequest);
Expand All @@ -144,6 +158,7 @@ export default class PostViewController extends React.Component {
onDeactivate() {
PreferenceStore.removeChangeListener(this.onPreferenceChange);
UserStore.removeChangeListener(this.onUserChange);
TeamStore.removeChangeListener(this.onTeamChange);
UserStore.removeStatusesChangeListener(this.onStatusChange);
PostStore.removeChangeListener(this.onPostsChange);
PostStore.removePostsViewJumpListener(this.onPostsViewJumpRequest);
Expand Down
3 changes: 3 additions & 0 deletions webapp/components/sidebar.jsx
Expand Up @@ -187,6 +187,9 @@ export default class Sidebar extends React.Component {
}

onChange() {
if (this.state.currentTeam.id !== TeamStore.getCurrentId()) {
ChannelStore.clear();
}
this.setState(this.getStateFromStores());
this.updateTitle();
}
Expand Down

0 comments on commit 04f4545

Please sign in to comment.