diff --git a/app/components/autocomplete/channel_mention/channel_mention.js b/app/components/autocomplete/channel_mention/channel_mention.js index c510f7074..6c6267180 100644 --- a/app/components/autocomplete/channel_mention/channel_mention.js +++ b/app/components/autocomplete/channel_mention/channel_mention.js @@ -6,6 +6,8 @@ import PropTypes from 'prop-types'; import {SectionList} from 'react-native'; import {RequestStatus} from 'mattermost-redux/constants'; +import {isMinimumServerVersion} from 'mattermost-redux/utils/helpers'; +import {debounce} from 'mattermost-redux/actions/helpers'; import {CHANNEL_MENTION_REGEX, CHANNEL_MENTION_SEARCH_REGEX} from 'app/constants/autocomplete'; import AutocompleteDivider from 'app/components/autocomplete/autocomplete_divider'; @@ -17,6 +19,7 @@ export default class ChannelMention extends PureComponent { static propTypes = { actions: PropTypes.shape({ searchChannels: PropTypes.func.isRequired, + autocompleteChannelsForSearch: PropTypes.func.isRequired, }).isRequired, currentTeamId: PropTypes.string.isRequired, cursorPosition: PropTypes.number.isRequired, @@ -34,6 +37,7 @@ export default class ChannelMention extends PureComponent { requestStatus: PropTypes.string.isRequired, theme: PropTypes.object.isRequired, value: PropTypes.string, + serverVersion: PropTypes.string, }; static defaultProps = { @@ -49,6 +53,15 @@ export default class ChannelMention extends PureComponent { }; } + runSearch = debounce((currentTeamId, matchTerm) => { + if (!isMinimumServerVersion(this.props.serverVersion, 5, 4)) { + this.props.actions.searchChannels(currentTeamId, matchTerm); + return; + } + + this.props.actions.autocompleteChannelsForSearch(currentTeamId, matchTerm); + }, 200); + componentWillReceiveProps(nextProps) { const {isSearch, matchTerm, myChannels, otherChannels, privateChannels, publicChannels, requestStatus, myMembers, deletedPublicChannels} = nextProps; @@ -70,7 +83,7 @@ export default class ChannelMention extends PureComponent { if (matchTerm !== this.props.matchTerm) { // if the term changed and we haven't made the request do that first const {currentTeamId} = this.props; - this.props.actions.searchChannels(currentTeamId, matchTerm); + this.runSearch(currentTeamId, matchTerm); return; } @@ -85,7 +98,7 @@ export default class ChannelMention extends PureComponent { sections.push({ id: 'suggestion.search.public', defaultMessage: 'Public Channels', - data: publicChannels.filter((cId) => !deletedPublicChannels.has(cId) || myMembers[cId]), + data: publicChannels.filter((cId) => myMembers[cId]), key: 'publicChannels', }); } diff --git a/app/components/autocomplete/channel_mention/index.js b/app/components/autocomplete/channel_mention/index.js index 57cea375c..1ac50077a 100644 --- a/app/components/autocomplete/channel_mention/index.js +++ b/app/components/autocomplete/channel_mention/index.js @@ -4,7 +4,7 @@ import {bindActionCreators} from 'redux'; import {connect} from 'react-redux'; -import {searchChannels} from 'mattermost-redux/actions/channels'; +import {searchChannels, autocompleteChannelsForSearch} from 'mattermost-redux/actions/channels'; import {getMyChannelMemberships} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams'; @@ -49,6 +49,7 @@ function mapStateToProps(state, ownProps) { matchTerm, requestStatus: state.requests.channels.getChannels.status, theme: getTheme(state), + serverVersion: state.entities.general.serverVersion, }; } @@ -56,6 +57,7 @@ function mapDispatchToProps(dispatch) { return { actions: bindActionCreators({ searchChannels, + autocompleteChannelsForSearch, }, dispatch), }; } diff --git a/app/components/autocomplete/emoji_suggestion/index.js b/app/components/autocomplete/emoji_suggestion/index.js index e0f179ce3..c6404202b 100644 --- a/app/components/autocomplete/emoji_suggestion/index.js +++ b/app/components/autocomplete/emoji_suggestion/index.js @@ -7,7 +7,6 @@ import {bindActionCreators} from 'redux'; import {getCustomEmojisByName} from 'mattermost-redux/selectors/entities/emojis'; import {autocompleteCustomEmojis} from 'mattermost-redux/actions/emojis'; -import {Client4} from 'mattermost-redux/client'; import {addReactionToLatestPost} from 'app/actions/views/emoji'; import {getTheme} from 'mattermost-redux/selectors/entities/preferences'; @@ -46,7 +45,7 @@ function mapStateToProps(state) { fuse, emojis, theme: getTheme(state), - serverVersion: state.entities.general.serverVersion || Client4.getServerVersion(), + serverVersion: state.entities.general.serverVersion, }; } diff --git a/app/components/emoji_picker/index.js b/app/components/emoji_picker/index.js index faaf2e07b..5c560709d 100644 --- a/app/components/emoji_picker/index.js +++ b/app/components/emoji_picker/index.js @@ -9,7 +9,6 @@ import {getTheme} from 'mattermost-redux/selectors/entities/preferences'; import {getCustomEmojisByName} from 'mattermost-redux/selectors/entities/emojis'; import {getConfig} from 'mattermost-redux/selectors/entities/general'; import {getCustomEmojis, searchCustomEmojis} from 'mattermost-redux/actions/emojis'; -import {Client4} from 'mattermost-redux/client'; import {incrementEmojiPickerPage} from 'app/actions/views/emoji'; import {getDimensions, isLandscape} from 'app/selectors/device'; @@ -160,7 +159,7 @@ function mapStateToProps(state) { theme: getTheme(state), customEmojisEnabled: getConfig(state).EnableCustomEmoji === 'true', customEmojiPage: state.views.emoji.emojiPickerCustomPage, - serverVersion: state.entities.general.serverVersion || Client4.getServerVersion(), + serverVersion: state.entities.general.serverVersion, }; } diff --git a/package-lock.json b/package-lock.json index a8f2687d3..0d9489687 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10178,8 +10178,8 @@ } }, "mattermost-redux": { - "version": "github:mattermost/mattermost-redux#f7a515c54b30fbb6aa0e8c374f3618eb7935c4c3", - "from": "github:mattermost/mattermost-redux#f7a515c54b30fbb6aa0e8c374f3618eb7935c4c3", + "version": "github:mattermost/mattermost-redux#c7aa1f1dc8dd67f9806b2cbb3a6103ff8a9c16fd", + "from": "github:mattermost/mattermost-redux#c7aa1f1dc8dd67f9806b2cbb3a6103ff8a9c16fd", "requires": { "deep-equal": "1.0.1", "eslint-plugin-header": "1.2.0", diff --git a/package.json b/package.json index bc72b7ed4..91ed561a5 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "intl": "1.2.5", "jail-monkey": "1.0.0", "jsc-android": "216113.0.3", - "mattermost-redux": "github:mattermost/mattermost-redux#f7a515c54b30fbb6aa0e8c374f3618eb7935c4c3", + "mattermost-redux": "github:mattermost/mattermost-redux#c7aa1f1dc8dd67f9806b2cbb3a6103ff8a9c16fd", "mime-db": "1.33.0", "moment-timezone": "0.5.21", "prop-types": "15.6.1",