[Gekidou MM-45506] Do not include empty DM and GMs in Channel List (#6630)
This commit is contained in:
parent
36846e9b4c
commit
9b41b21319
2 changed files with 21 additions and 4 deletions
|
|
@ -436,6 +436,16 @@ export const queryMyChannelUnreads = (database: Database, currentTeamId: string)
|
|||
);
|
||||
};
|
||||
|
||||
export const queryEmptyDirectAndGroupChannels = (database: Database) => {
|
||||
return database.get<MyChannelModel>(MY_CHANNEL).query(
|
||||
Q.on(
|
||||
CHANNEL,
|
||||
Q.where('team_id', Q.eq('')),
|
||||
),
|
||||
Q.where('last_post_at', Q.eq(0)),
|
||||
);
|
||||
};
|
||||
|
||||
export function observeMyChannelMentionCount(database: Database, teamId?: string, columns = ['mentions_count', 'is_unread']): Observable<number> {
|
||||
const conditions: Q.Condition[] = [
|
||||
Q.where('delete_at', Q.eq(0)),
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@ import withObservables from '@nozbe/with-observables';
|
|||
import {combineLatest, of as of$} from 'rxjs';
|
||||
import {map, switchMap, combineLatestWith} from 'rxjs/operators';
|
||||
|
||||
import {MyChannelModel} from '@app/database/models/server';
|
||||
import {General, Preferences} from '@constants';
|
||||
import {DMS_CATEGORY} from '@constants/categories';
|
||||
import {getPreferenceAsBool} from '@helpers/api/preference';
|
||||
import {observeChannelsByCategoryChannelSortOrder, observeChannelsByLastPostAtInCategory} from '@queries/servers/categories';
|
||||
import {observeNotifyPropsByChannels, queryChannelsByNames} from '@queries/servers/channel';
|
||||
import {observeNotifyPropsByChannels, queryChannelsByNames, queryEmptyDirectAndGroupChannels} from '@queries/servers/channel';
|
||||
import {queryPreferencesByCategoryAndName} from '@queries/servers/preference';
|
||||
import {observeCurrentChannelId, observeCurrentUserId, observeLastUnreadChannelId} from '@queries/servers/system';
|
||||
import {getDirectChannelName} from '@utils/channel';
|
||||
|
|
@ -86,7 +87,7 @@ const observeSortedChannels = (database: Database, category: CategoryModel, excl
|
|||
|
||||
const mapPrefName = (prefs: PreferenceModel[]) => of$(prefs.map((p) => p.name));
|
||||
|
||||
const mapChannelIds = (channels: ChannelModel[]) => of$(channels.map((c) => c.id));
|
||||
const mapChannelIds = (channels: ChannelModel[] | MyChannelModel[]) => of$(channels.map((c) => c.id));
|
||||
|
||||
const withUserId = withObservables([], ({database}: WithDatabaseArgs) => ({currentUserId: observeCurrentUserId(database)}));
|
||||
|
||||
|
|
@ -107,11 +108,17 @@ const enhance = withObservables(['category', 'isTablet', 'locale'], ({category,
|
|||
}),
|
||||
);
|
||||
|
||||
const emptyDmIds = queryEmptyDirectAndGroupChannels(database).observeWithColumns(['last_post_at']).pipe(
|
||||
switchMap(mapChannelIds),
|
||||
);
|
||||
|
||||
const hiddenChannelIds = queryPreferencesByCategoryAndName(database, Preferences.CATEGORY_GROUP_CHANNEL_SHOW, undefined, 'false').
|
||||
observeWithColumns(['value']).pipe(
|
||||
switchMap(mapPrefName),
|
||||
combineLatestWith(hiddenDmIds),
|
||||
switchMap(([a, b]) => of$(new Set(a.concat(b)))),
|
||||
combineLatestWith(hiddenDmIds, emptyDmIds),
|
||||
switchMap(([hIds, hDmIds, eDmIds]) => {
|
||||
return of$(new Set(hIds.concat(hDmIds, eDmIds)));
|
||||
}),
|
||||
);
|
||||
|
||||
const sortedChannels = hiddenChannelIds.pipe(
|
||||
|
|
|
|||
Loading…
Reference in a new issue