From b4002ba55f9a96ca2f21b3ad2afced37b47ac69e Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 1 Nov 2016 12:58:04 -0400 Subject: Plt-4483 Removed unnecessary events from ChannelStore (#4407) * PLT-4483 Removed MoreChange listener from ChannelStore * PLT-4483 Removed LeaveChannel listener from ChannelStore --- webapp/components/channel_header.jsx | 8 +--- webapp/components/more_channels.jsx | 4 +- .../components/post_message_container.jsx | 2 - webapp/stores/channel_store.jsx | 45 ++-------------------- webapp/utils/constants.jsx | 1 - 5 files changed, 6 insertions(+), 54 deletions(-) (limited to 'webapp') diff --git a/webapp/components/channel_header.jsx b/webapp/components/channel_header.jsx index 2d3de5998..b92a316ca 100644 --- a/webapp/components/channel_header.jsx +++ b/webapp/components/channel_header.jsx @@ -23,7 +23,6 @@ import SearchStore from 'stores/search_store.jsx'; import PreferenceStore from 'stores/preference_store.jsx'; import WebrtcStore from 'stores/webrtc_store.jsx'; -import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; import * as GlobalActions from 'actions/global_actions.jsx'; import * as WebrtcActions from 'actions/webrtc_actions.jsx'; import * as ChannelActions from 'actions/channel_actions.jsx'; @@ -34,7 +33,7 @@ import Client from 'client/web_client.jsx'; import * as AsyncClient from 'utils/async_client.jsx'; import {getFlaggedPosts} from 'actions/post_actions.jsx'; -import {ActionTypes, Constants, Preferences, UserStatuses} from 'utils/constants.jsx'; +import {Constants, Preferences, UserStatuses} from 'utils/constants.jsx'; import React from 'react'; import {FormattedMessage} from 'react-intl'; @@ -130,11 +129,6 @@ export default class ChannelHeader extends React.Component { () => { const channelId = this.state.channel.id; - AppDispatcher.handleViewAction({ - type: ActionTypes.LEAVE_CHANNEL, - id: channelId - }); - if (this.state.isFavorite) { ChannelActions.unmarkFavorite(channelId); } diff --git a/webapp/components/more_channels.jsx b/webapp/components/more_channels.jsx index b72f9aedd..b35f5b997 100644 --- a/webapp/components/more_channels.jsx +++ b/webapp/components/more_channels.jsx @@ -41,7 +41,7 @@ export default class MoreChannels extends React.Component { componentDidMount() { const self = this; - ChannelStore.addMoreChangeListener(this.onListenerChange); + ChannelStore.addChangeListener(this.onListenerChange); $(this.refs.modal).on('shown.bs.modal', () => { AsyncClient.getMoreChannels(true); @@ -54,7 +54,7 @@ export default class MoreChannels extends React.Component { } componentWillUnmount() { - ChannelStore.removeMoreChangeListener(this.onListenerChange); + ChannelStore.removeChangeListener(this.onListenerChange); } getStateFromStores() { diff --git a/webapp/components/post_view/components/post_message_container.jsx b/webapp/components/post_view/components/post_message_container.jsx index 00d0097ca..2d17e74c4 100644 --- a/webapp/components/post_view/components/post_message_container.jsx +++ b/webapp/components/post_view/components/post_message_container.jsx @@ -48,7 +48,6 @@ export default class PostMessageContainer extends React.Component { PreferenceStore.addChangeListener(this.onPreferenceChange); UserStore.addChangeListener(this.onUserChange); ChannelStore.addChangeListener(this.onChannelChange); - ChannelStore.addMoreChangeListener(this.onChannelChange); } componentWillUnmount() { @@ -56,7 +55,6 @@ export default class PostMessageContainer extends React.Component { PreferenceStore.removeChangeListener(this.onPreferenceChange); UserStore.removeChangeListener(this.onUserChange); ChannelStore.removeChangeListener(this.onChannelChange); - ChannelStore.removeMoreChangeListener(this.onChannelChange); } onEmojiChange() { diff --git a/webapp/stores/channel_store.jsx b/webapp/stores/channel_store.jsx index 3212c1155..13a5c4574 100644 --- a/webapp/stores/channel_store.jsx +++ b/webapp/stores/channel_store.jsx @@ -5,13 +5,10 @@ import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; import EventEmitter from 'events'; var Utils; -import Constants from 'utils/constants.jsx'; -const ActionTypes = Constants.ActionTypes; +import {ActionTypes, Constants} from 'utils/constants.jsx'; const NotificationPrefs = Constants.NotificationPrefs; const CHANGE_EVENT = 'change'; -const LEAVE_EVENT = 'leave'; -const MORE_CHANGE_EVENT = 'change'; const STATS_EVENT = 'stats'; const LAST_VIEVED_EVENT = 'last_viewed'; @@ -50,18 +47,6 @@ class ChannelStoreClass extends EventEmitter { this.removeListener(CHANGE_EVENT, callback); } - emitMoreChange() { - this.emit(MORE_CHANGE_EVENT); - } - - addMoreChangeListener(callback) { - this.on(MORE_CHANGE_EVENT, callback); - } - - removeMoreChangeListener(callback) { - this.removeListener(MORE_CHANGE_EVENT, callback); - } - emitStatsChange() { this.emit(STATS_EVENT); } @@ -73,17 +58,6 @@ class ChannelStoreClass extends EventEmitter { removeStatsChangeListener(callback) { this.removeListener(STATS_EVENT, callback); } - emitLeave(id) { - this.emit(LEAVE_EVENT, id); - } - - addLeaveListener(callback) { - this.on(LEAVE_EVENT, callback); - } - - removeLeaveListener(callback) { - this.removeListener(LEAVE_EVENT, callback); - } emitLastViewed(lastViewed, ownNewMessage) { this.emit(LAST_VIEVED_EVENT, lastViewed, ownNewMessage); @@ -321,14 +295,6 @@ class ChannelStoreClass extends EventEmitter { return this.unreadCounts; } - leaveChannel(id) { - Reflect.deleteProperty(this.myChannelMembers, id); - const element = this.channels.indexOf(id); - if (element > -1) { - this.channels.splice(element, 1); - } - } - getChannelNamesMap() { var channelNamesMap = {}; @@ -404,7 +370,7 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => { break; case ActionTypes.RECEIVED_MORE_CHANNELS: ChannelStore.storeMoreChannels(action.channels); - ChannelStore.emitMoreChange(); + ChannelStore.emitChange(); break; case ActionTypes.RECEIVED_CHANNEL_STATS: @@ -414,14 +380,9 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => { ChannelStore.emitStatsChange(); break; - case ActionTypes.LEAVE_CHANNEL: - ChannelStore.leaveChannel(action.id); - ChannelStore.emitLeave(action.id); - break; - default: break; } }); -export default ChannelStore; +export default ChannelStore; \ No newline at end of file diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index 6ea8d040e..beaca3921 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -63,7 +63,6 @@ export const ActionTypes = keyMirror({ CLICK_CHANNEL: null, CREATE_CHANNEL: null, - LEAVE_CHANNEL: null, CREATE_POST: null, CREATE_COMMENT: null, POST_DELETED: null, -- cgit v1.2.3-1-g7c22