Add websocket event and cache invalidation for deleting channels (#2807)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
ada513a014
Коммит
7695cbd1b4
@@ -18,6 +18,8 @@ import * as GlobalActions from 'action_creators/global_actions.jsx';
|
||||
import Constants from 'utils/constants.jsx';
|
||||
const SocketEvents = Constants.SocketEvents;
|
||||
|
||||
import {browserHistory} from 'react-router';
|
||||
|
||||
const MAX_WEBSOCKET_FAILS = 7;
|
||||
const WEBSOCKET_RETRY_TIME = 3000;
|
||||
|
||||
@@ -135,6 +137,10 @@ function handleMessage(msg) {
|
||||
handleChannelViewedEvent(msg);
|
||||
break;
|
||||
|
||||
case SocketEvents.CHANNEL_DELETED:
|
||||
handleChannelDeletedEvent(msg);
|
||||
break;
|
||||
|
||||
case SocketEvents.PREFERENCE_CHANGED:
|
||||
handlePreferenceChangedEvent(msg);
|
||||
break;
|
||||
@@ -234,6 +240,15 @@ function handleChannelViewedEvent(msg) {
|
||||
}
|
||||
}
|
||||
|
||||
function handleChannelDeletedEvent(msg) {
|
||||
if (ChannelStore.getCurrentId() === msg.channel_id) {
|
||||
const teamUrl = TeamStore.getCurrentTeamRelativeUrl();
|
||||
browserHistory.push(teamUrl + '/channels/' + Constants.DEFAULT_CHANNEL);
|
||||
} else {
|
||||
AsyncClient.getChannels();
|
||||
}
|
||||
}
|
||||
|
||||
function handlePreferenceChangedEvent(msg) {
|
||||
const preference = JSON.parse(msg.props.preference);
|
||||
GlobalActions.emitPreferenceChangedEvent(preference);
|
||||
|
||||
@@ -20,19 +20,6 @@ function getWindowLocationOrigin() {
|
||||
class TeamStoreClass extends EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.emitChange = this.emitChange.bind(this);
|
||||
this.addChangeListener = this.addChangeListener.bind(this);
|
||||
this.removeChangeListener = this.removeChangeListener.bind(this);
|
||||
this.get = this.get.bind(this);
|
||||
this.getByName = this.getByName.bind(this);
|
||||
this.getAll = this.getAll.bind(this);
|
||||
this.getCurrentId = this.getCurrentId.bind(this);
|
||||
this.getCurrent = this.getCurrent.bind(this);
|
||||
this.getCurrentTeamUrl = this.getCurrentTeamUrl.bind(this);
|
||||
this.getCurrentInviteLink = this.getCurrentInviteLink.bind(this);
|
||||
this.saveTeam = this.saveTeam.bind(this);
|
||||
|
||||
this.clear();
|
||||
}
|
||||
|
||||
@@ -104,6 +91,13 @@ class TeamStoreClass extends EventEmitter {
|
||||
return null;
|
||||
}
|
||||
|
||||
getCurrentTeamRelativeUrl() {
|
||||
if (this.getCurrent()) {
|
||||
return '/' + this.getCurrent().name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getCurrentInviteLink() {
|
||||
const current = this.getCurrent();
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ export default {
|
||||
POSTED: 'posted',
|
||||
POST_EDITED: 'post_edited',
|
||||
POST_DELETED: 'post_deleted',
|
||||
CHANNEL_DELETED: 'channel_deleted',
|
||||
CHANNEL_VIEWED: 'channel_viewed',
|
||||
NEW_USER: 'new_user',
|
||||
USER_ADDED: 'user_added',
|
||||
|
||||
Ссылка в новой задаче
Block a user