From c84b05217bb5ad75161961fd69be4e5bd7e9562a Mon Sep 17 00:00:00 2001 From: Eli Yukelzon Date: Mon, 17 Jun 2019 17:22:36 +0300 Subject: [PATCH] MM-15486 - Archived channels appear incorrectly on mobile (#2882) * properly separate archived channels from 'other' * make sure fetch is performed to display full list * reverted unneeded change * corrected display behaviour * code cleanup * redux commit reference updated --- .../filtered_list/filtered_list.js | 19 +++++++++++++++++++ .../main/channels_list/filtered_list/index.js | 6 ++++-- assets/base/i18n/en.json | 1 + package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/app/components/sidebars/main/channels_list/filtered_list/filtered_list.js b/app/components/sidebars/main/channels_list/filtered_list/filtered_list.js index 39d652c95..7546f3630 100644 --- a/app/components/sidebars/main/channels_list/filtered_list/filtered_list.js +++ b/app/components/sidebars/main/channels_list/filtered_list/filtered_list.js @@ -44,6 +44,7 @@ class FilteredList extends Component { teammateNameDisplay: PropTypes.string, onSelectChannel: PropTypes.func.isRequired, otherChannels: PropTypes.array, + archivedChannels: PropTypes.array, profiles: PropTypes.object, teamProfiles: PropTypes.object, searchOrder: PropTypes.array.isRequired, @@ -176,6 +177,11 @@ class FilteredList extends Component { id: t('mobile.channel_list.not_member'), defaultMessage: 'NOT A MEMBER', }, + archived: { + builder: this.buildArchivedForSearch, + id: t('mobile.channel_list.archived'), + defaultMessage: 'ARCHIVED', + }, }); buildUnreadChannelsForSearch = (props, term) => { @@ -294,6 +300,19 @@ class FilteredList extends Component { sort(sortChannelsByDisplayName.bind(null, props.intl.locale)); } + buildArchivedForSearch = (props, term) => { + const {currentChannel, archivedChannels} = props; + + return this.filterChannels(archivedChannels.reduce((acc, channel) => { + // when there is no search text, display an archived channel only if we are in it at the moment. + if (term || channel.id === currentChannel.id) { + acc.push({...channel}); + } + + return acc; + }, []), term); + } + buildOtherMembersForSearch = (props, term) => { const {otherChannels} = props; diff --git a/app/components/sidebars/main/channels_list/filtered_list/index.js b/app/components/sidebars/main/channels_list/filtered_list/index.js index 1ab751b4e..a9dac6a0f 100644 --- a/app/components/sidebars/main/channels_list/filtered_list/index.js +++ b/app/components/sidebars/main/channels_list/filtered_list/index.js @@ -13,6 +13,7 @@ import { getChannelsWithUnreadSection, getCurrentChannel, getGroupChannels, + getArchivedChannels, getOtherChannels, } from 'mattermost-redux/selectors/entities/channels'; import {getConfig} from 'mattermost-redux/selectors/entities/general'; @@ -24,7 +25,7 @@ import Config from 'assets/config'; import FilteredList from './filtered_list'; -const DEFAULT_SEARCH_ORDER = ['unreads', 'dms', 'channels', 'members', 'nonmembers']; +const DEFAULT_SEARCH_ORDER = ['unreads', 'dms', 'channels', 'members', 'nonmembers', 'archived']; const pastDirectMessages = createSelector( getDirectShowPreferences, @@ -112,7 +113,8 @@ function mapStateToProps(state) { currentChannel: getCurrentChannel(state), currentTeam: getCurrentTeam(state), currentUserId, - otherChannels: getOtherChannels(state), + otherChannels: getOtherChannels(state, false), + archivedChannels: getArchivedChannels(state), groupChannelMemberDetails: getGroupChannelMemberDetails(state), profiles, teamProfiles, diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json index 030d4246c..0deadc73a 100644 --- a/assets/base/i18n/en.json +++ b/assets/base/i18n/en.json @@ -165,6 +165,7 @@ "mobile.channel_info.publicChannel": "Public Channel", "mobile.channel_list.alertNo": "No", "mobile.channel_list.alertYes": "Yes", + "mobile.channel_list.archived": "ARCHIVED", "mobile.channel_list.channels": "CHANNELS", "mobile.channel_list.closeDM": "Close Direct Message", "mobile.channel_list.closeGM": "Close Group Message", diff --git a/package-lock.json b/package-lock.json index 63e55e7c4..03fc24c64 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13134,8 +13134,8 @@ "integrity": "sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==" }, "mattermost-redux": { - "version": "github:mattermost/mattermost-redux#80407bc07f477eaeb93be4045a686b6bf977697f", - "from": "github:mattermost/mattermost-redux#80407bc07f477eaeb93be4045a686b6bf977697f", + "version": "github:mattermost/mattermost-redux#6df64ba38d8b68c63c568b1259f6a5b660d1879f", + "from": "github:mattermost/mattermost-redux#6df64ba38d8b68c63c568b1259f6a5b660d1879f", "requires": { "deep-equal": "1.0.1", "eslint-plugin-header": "3.0.0", diff --git a/package.json b/package.json index 659e76c39..ee73523c6 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "intl": "1.2.5", "jail-monkey": "2.2.0", "jsc-android": "241213.1.0", - "mattermost-redux": "github:mattermost/mattermost-redux#80407bc07f477eaeb93be4045a686b6bf977697f", + "mattermost-redux": "github:mattermost/mattermost-redux#6df64ba38d8b68c63c568b1259f6a5b660d1879f", "mime-db": "1.40.0", "moment-timezone": "0.5.25", "prop-types": "15.7.2",