MM-12959: Fix autocomplete archived channels visibility (#2367)
* MM-12959: Fix autocomplete archived channels visibility * Remove unneeded getDeletedPublicChannels
This commit is contained in:
parent
de812107b5
commit
8097764d87
3 changed files with 17 additions and 24 deletions
|
|
@ -35,7 +35,6 @@ export default class ChannelMention extends PureComponent {
|
|||
privateChannels: PropTypes.array,
|
||||
publicChannels: PropTypes.array,
|
||||
directAndGroupMessages: PropTypes.array,
|
||||
deletedPublicChannels: PropTypes.instanceOf(Set),
|
||||
requestStatus: PropTypes.string.isRequired,
|
||||
theme: PropTypes.object.isRequired,
|
||||
value: PropTypes.string,
|
||||
|
|
@ -64,7 +63,7 @@ export default class ChannelMention extends PureComponent {
|
|||
}, 200);
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const {isSearch, matchTerm, myChannels, otherChannels, privateChannels, publicChannels, directAndGroupMessages, requestStatus, myMembers, deletedPublicChannels} = nextProps;
|
||||
const {isSearch, matchTerm, myChannels, otherChannels, privateChannels, publicChannels, directAndGroupMessages, requestStatus, myMembers} = nextProps;
|
||||
|
||||
if ((matchTerm !== this.props.matchTerm && matchTerm === null) || this.state.mentionComplete) {
|
||||
// if the term changes but is null or the mention has been completed we render this component as null
|
||||
|
|
@ -89,7 +88,7 @@ export default class ChannelMention extends PureComponent {
|
|||
if (matchTerm === '' || (myChannels !== this.props.myChannels || otherChannels !== this.props.otherChannels ||
|
||||
privateChannels !== this.props.privateChannels || publicChannels !== this.props.publicChannels ||
|
||||
directAndGroupMessages !== this.props.directAndGroupMessages ||
|
||||
myMembers !== this.props.myMembers || deletedPublicChannels !== this.props.deletedPublicChannels)) {
|
||||
myMembers !== this.props.myMembers)) {
|
||||
const sections = [];
|
||||
if (isSearch) {
|
||||
if (publicChannels.length) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import {
|
|||
filterPublicChannels,
|
||||
filterPrivateChannels,
|
||||
filterDirectAndGroupMessages,
|
||||
getDeletedPublicChannelsIds,
|
||||
getMatchTermForChannelMention,
|
||||
} from 'app/selectors/autocomplete';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
|
|
@ -46,7 +45,6 @@ function mapStateToProps(state, ownProps) {
|
|||
myMembers: getMyChannelMemberships(state),
|
||||
otherChannels,
|
||||
publicChannels,
|
||||
deletedPublicChannels: getDeletedPublicChannelsIds(state),
|
||||
privateChannels,
|
||||
directAndGroupMessages,
|
||||
currentTeamId: getCurrentTeamId(state),
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
import {createSelector} from 'reselect';
|
||||
|
||||
import {General} from 'mattermost-redux/constants';
|
||||
import {getConfig} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getMyChannels, getOtherChannels} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {
|
||||
getCurrentUser, getCurrentUserId, getProfilesInCurrentChannel,
|
||||
|
|
@ -184,7 +185,8 @@ export const filterPublicChannels = createSelector(
|
|||
getOtherChannels,
|
||||
getCurrentLocale,
|
||||
(state, matchTerm) => matchTerm,
|
||||
(myChannels, otherChannels, locale, matchTerm) => {
|
||||
getConfig,
|
||||
(myChannels, otherChannels, locale, matchTerm, config) => {
|
||||
if (matchTerm === null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -203,6 +205,11 @@ export const filterPublicChannels = createSelector(
|
|||
}).concat(otherChannels);
|
||||
}
|
||||
|
||||
const viewArchivedChannels = config.ExperimentalViewArchivedChannels === 'true';
|
||||
if (!viewArchivedChannels) {
|
||||
channels = channels.filter((c) => c.delete_at === 0);
|
||||
}
|
||||
|
||||
return channels.sort(sortChannelsByDisplayName.bind(null, locale)).map((c) => c.id);
|
||||
}
|
||||
);
|
||||
|
|
@ -210,7 +217,8 @@ export const filterPublicChannels = createSelector(
|
|||
export const filterPrivateChannels = createSelector(
|
||||
getMyChannels,
|
||||
(state, matchTerm) => matchTerm,
|
||||
(myChannels, matchTerm) => {
|
||||
getConfig,
|
||||
(myChannels, matchTerm, config) => {
|
||||
if (matchTerm === null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -227,6 +235,11 @@ export const filterPrivateChannels = createSelector(
|
|||
});
|
||||
}
|
||||
|
||||
const viewArchivedChannels = config.ExperimentalViewArchivedChannels === 'true';
|
||||
if (!viewArchivedChannels) {
|
||||
channels = channels.filter((c) => c.delete_at === 0);
|
||||
}
|
||||
|
||||
return channels.map((c) => c.id);
|
||||
}
|
||||
);
|
||||
|
|
@ -278,20 +291,3 @@ export const makeGetMatchTermForDateMention = () => {
|
|||
return lastMatchTerm;
|
||||
};
|
||||
};
|
||||
|
||||
export const getDeletedPublicChannelsIds = createSelector(
|
||||
getMyChannels,
|
||||
getOtherChannels,
|
||||
(myChannels, otherChannels) => {
|
||||
const channels = myChannels.filter((c) => {
|
||||
return (c.type === General.OPEN_CHANNEL);
|
||||
}).concat(otherChannels);
|
||||
|
||||
return new Set(channels.reduce((acc, c) => {
|
||||
if (c.delete_at !== 0) {
|
||||
acc.push(c.id);
|
||||
}
|
||||
return acc;
|
||||
}, []));
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue