diff --git a/webapp/channels/src/components/suggestion/search_channel_with_permissions_provider.test.jsx b/webapp/channels/src/components/suggestion/search_channel_with_permissions_provider.test.tsx similarity index 98% rename from webapp/channels/src/components/suggestion/search_channel_with_permissions_provider.test.jsx rename to webapp/channels/src/components/suggestion/search_channel_with_permissions_provider.test.tsx index 6e15862f60..c75b197838 100644 --- a/webapp/channels/src/components/suggestion/search_channel_with_permissions_provider.test.jsx +++ b/webapp/channels/src/components/suggestion/search_channel_with_permissions_provider.test.tsx @@ -1,12 +1,13 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {getState} from 'stores/redux_store'; - +import store from 'stores/redux_store'; import mockStore from 'tests/test_store'; import SearchChannelWithPermissionsProvider from './search_channel_with_permissions_provider'; +const getState = store.getState; + jest.mock('stores/redux_store', () => ({ dispatch: jest.fn(), getState: jest.fn(), @@ -114,7 +115,7 @@ describe('components/SearchChannelWithPermissionsProvider', () => { }, }; - let searchProvider; + let searchProvider: SearchChannelWithPermissionsProvider; beforeEach(() => { const channelSearchFunc = jest.fn(); diff --git a/webapp/channels/src/components/suggestion/search_channel_with_permissions_provider.tsx b/webapp/channels/src/components/suggestion/search_channel_with_permissions_provider.tsx index 7152d00959..9d0ca7df43 100644 --- a/webapp/channels/src/components/suggestion/search_channel_with_permissions_provider.tsx +++ b/webapp/channels/src/components/suggestion/search_channel_with_permissions_provider.tsx @@ -24,11 +24,15 @@ import {Constants} from 'utils/constants'; import Provider, {ResultsCallback} from './provider'; import {SuggestionContainer, SuggestionProps} from './suggestion'; -type WrappedChannel = { +interface WrappedChannel { channel: Channel; - name: string; + name: Channel['name']; + deactivated: boolean; + type: Channel['type']; } +type ChannelSearchFunction = (teamId: string, channelPrefix: string) => Promise + const SearchChannelWithPermissionsSuggestion = React.forwardRef>((props, ref) => { const {item} = props; const channel = item.channel; @@ -97,9 +101,9 @@ function channelSearchSorter(wrappedA: WrappedChannel, wrappedB: WrappedChannel) } export default class SearchChannelWithPermissionsProvider extends Provider { - autocompleteChannelsForSearch: (channelId: string, userId: string) => Promise>; + autocompleteChannelsForSearch: ChannelSearchFunction; - constructor(channelSearchFunc: SearchChannelWithPermissionsProvider['autocompleteChannelsForSearch']) { + constructor(channelSearchFunc: ChannelSearchFunction) { super(); this.autocompleteChannelsForSearch = channelSearchFunc; } @@ -179,7 +183,7 @@ export default class SearchChannelWithPermissionsProvider extends Provider { return; } - const completedChannels: Record = {}; + const completedChannels: Record = {}; const channelFilter = this.makeChannelSearchFilter(channelPrefix); @@ -187,10 +191,6 @@ export default class SearchChannelWithPermissionsProvider extends Provider { const viewArchivedChannels = config.ExperimentalViewArchivedChannels === 'true'; for (const channel of allChannels) { - if (!channel) { - continue; - } - if (completedChannels[channel.id]) { continue; } @@ -199,10 +199,7 @@ export default class SearchChannelWithPermissionsProvider extends Provider { const newChannel = Object.assign({}, channel); const channelIsArchived = channel.delete_at !== 0; - const wrappedChannel = { - channel: newChannel, - name: newChannel.name, - }; + const wrappedChannel = {channel: newChannel, name: newChannel.name, deactivated: false, type: newChannel.type}; if (!viewArchivedChannels && channelIsArchived) { continue; } else if (!members[channel.id]) {