From ef363fd88ebb731dbb0470ad7cb5f50de0f3845c Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 28 Oct 2016 12:41:28 -0400 Subject: [PATCH] Fix channel autocomplete and fix channel member query to ignore deleted channels (#4371) --- store/sql_channel_store.go | 1 + webapp/components/more_channels.jsx | 57 ++++++++++++++--------------- webapp/stores/channel_store.jsx | 9 +---- 3 files changed, 30 insertions(+), 37 deletions(-) diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go index d1d48ef696..8b77ab6ff5 100644 --- a/store/sql_channel_store.go +++ b/store/sql_channel_store.go @@ -1040,6 +1040,7 @@ func (s SqlChannelStore) GetMembersForUser(teamId string, userId string) StoreCh INNER JOIN Channels c ON c.Id = cm.ChannelId AND (c.TeamId = :TeamId OR c.TeamId = '') + AND c.DeleteAt = 0 WHERE cm.UserId = :UserId `, map[string]interface{}{"TeamId": teamId, "UserId": userId}) diff --git a/webapp/components/more_channels.jsx b/webapp/components/more_channels.jsx index 00e7ecf787..b72f9aedd6 100644 --- a/webapp/components/more_channels.jsx +++ b/webapp/components/more_channels.jsx @@ -31,10 +31,12 @@ export default class MoreChannels extends React.Component { this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this); - const initState = this.getStateFromStores(); - initState.channelType = ''; - initState.showNewChannelModal = false; - this.state = initState; + this.state = { + channelType: '', + showNewChannelModal: false, + channels: null, + serverError: null + }; } componentDidMount() { @@ -140,31 +142,28 @@ export default class MoreChannels extends React.Component { } let moreChannels; - - if (this.state.channels != null) { - var channels = this.state.channels; - if (channels.loading) { - moreChannels = ; - } else if (channels.length) { - moreChannels = ( - - ); - } else { - moreChannels = ( -
-

- -

- {createChannelHelpText} -
- ); - } + const channels = this.state.channels; + if (channels == null) { + moreChannels = ; + } else if (channels.length) { + moreChannels = ( + + ); + } else { + moreChannels = ( +
+

+ +

+ {createChannelHelpText} +
+ ); } return ( diff --git a/webapp/stores/channel_store.jsx b/webapp/stores/channel_store.jsx index 16a094c7bf..f0258d02af 100644 --- a/webapp/stores/channel_store.jsx +++ b/webapp/stores/channel_store.jsx @@ -26,7 +26,6 @@ class ChannelStoreClass extends EventEmitter { this.channels = []; this.myChannelMembers = {}; this.moreChannels = {}; - this.moreChannels.loading = true; this.stats = {}; this.unreadCounts = {}; } @@ -300,13 +299,7 @@ class ChannelStoreClass extends EventEmitter { const ch = this.get(id); const chMember = this.getMyMember(id); - if (ch == null) { - console.log('setUnreadCountByChannel: missing channel id ' + id); //eslint-disable-line no-console - return; - } - - if (chMember == null) { - console.log('setUnreadCountByChannel: missing channel member for channel id ' + id); //eslint-disable-line no-console + if (ch == null || chMember == null) { return; }