Merge pull request #7505 from mattermost/MM-53849-mobile-hide-channels-from-archived-teams
MM-53849 - hide channels from archived teams during channels search
This commit is contained in:
commit
ccdab81d7e
3 changed files with 23 additions and 4 deletions
|
|
@ -12,7 +12,7 @@ import {observeConfigValue, observeCurrentTeamId} from '@queries/servers/system'
|
|||
import {queryJoinedTeams} from '@queries/servers/team';
|
||||
import {observeIsCRTEnabled} from '@queries/servers/thread';
|
||||
import {observeTeammateNameDisplay} from '@queries/servers/user';
|
||||
import {retrieveChannels} from '@screens/find_channels/utils';
|
||||
import {removeChannelsFromArchivedTeams, retrieveChannels} from '@screens/find_channels/utils';
|
||||
|
||||
import FilteredList, {MAX_RESULTS} from './filtered_list';
|
||||
|
||||
|
|
@ -37,11 +37,15 @@ const enhanced = withObservables(['term'], ({database, term}: EnhanceProps) => {
|
|||
switchMap((matchStart) => {
|
||||
return retrieveChannels(database, matchStart.flat(), true);
|
||||
}),
|
||||
combineLatestWith(teamIds),
|
||||
switchMap(([myChannels, tmIds]) => of$(removeChannelsFromArchivedTeams(myChannels, tmIds))),
|
||||
);
|
||||
|
||||
const channelsMatch = joinedChannelsMatch.pipe(
|
||||
combineLatestWith(directChannelsMatch),
|
||||
switchMap((matched) => retrieveChannels(database, matched.flat(), true)),
|
||||
combineLatestWith(teamIds),
|
||||
switchMap(([myChannels, tmIds]) => of$(removeChannelsFromArchivedTeams(myChannels, tmIds))),
|
||||
);
|
||||
|
||||
const archivedChannels = observeArchiveChannelsByTerm(database, term, MAX_RESULTS).pipe(
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider';
|
||||
import withObservables from '@nozbe/with-observables';
|
||||
import {of as of$} from 'rxjs';
|
||||
import {switchMap} from 'rxjs/operators';
|
||||
import {Observable, of as of$} from 'rxjs';
|
||||
import {combineLatestWith, switchMap} from 'rxjs/operators';
|
||||
|
||||
import {queryMyRecentChannels} from '@queries/servers/channel';
|
||||
import {queryJoinedTeams} from '@queries/servers/team';
|
||||
import {retrieveChannels} from '@screens/find_channels/utils';
|
||||
import {removeChannelsFromArchivedTeams, retrieveChannels} from '@screens/find_channels/utils';
|
||||
|
||||
import UnfilteredList from './unfiltered_list';
|
||||
|
||||
|
|
@ -18,10 +18,16 @@ const MAX_CHANNELS = 20;
|
|||
|
||||
const enhanced = withObservables([], ({database}: WithDatabaseArgs) => {
|
||||
const teamsCount = queryJoinedTeams(database).observeCount();
|
||||
const teamIds: Observable<Set<string>> = queryJoinedTeams(database).observe().pipe(
|
||||
// eslint-disable-next-line max-nested-callbacks
|
||||
switchMap((teams) => of$(new Set(teams.map((t) => t.id)))),
|
||||
);
|
||||
|
||||
const recentChannels = queryMyRecentChannels(database, MAX_CHANNELS).
|
||||
observeWithColumns(['last_viewed_at']).pipe(
|
||||
switchMap((myChannels) => retrieveChannels(database, myChannels, true)),
|
||||
combineLatestWith(teamIds),
|
||||
switchMap(([myChannels, tmIds]) => of$(removeChannelsFromArchivedTeams(myChannels, tmIds))),
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -25,3 +25,12 @@ export const retrieveChannels = (database: Database, myChannels: MyChannelModel[
|
|||
|
||||
return of$([]);
|
||||
};
|
||||
|
||||
export const removeChannelsFromArchivedTeams = (recentChannels: ChannelModel[], teamIds: Set<string>) => {
|
||||
return recentChannels.filter((channel) => {
|
||||
if (!channel.teamId) {
|
||||
return true;
|
||||
}
|
||||
return teamIds.has(channel.teamId);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue