diff --git a/app/database/models/server/category.ts b/app/database/models/server/category.ts index dfaeeb245a..8975cdcfc5 100644 --- a/app/database/models/server/category.ts +++ b/app/database/models/server/category.ts @@ -104,11 +104,11 @@ export default class CategoryModel extends Model implements CategoryInterface { Q.sortBy('last_post_at', Q.desc), ); - observeHasChannels = (canViewArchived: boolean) => { + observeHasChannels = (canViewArchived: boolean, channelId: string) => { return this.channels.observeWithColumns(['delete_at']).pipe( map((channels) => { if (canViewArchived) { - return channels.length > 0; + return channels.filter((c) => c.deleteAt === 0 || c.id === channelId).length > 0; } return channels.filter((c) => c.deleteAt === 0).length > 0; diff --git a/app/screens/home/channel_list/categories_list/categories/header/index.ts b/app/screens/home/channel_list/categories_list/categories/header/index.ts index 27048f40f5..5250f56c76 100644 --- a/app/screens/home/channel_list/categories_list/categories/header/index.ts +++ b/app/screens/home/channel_list/categories_list/categories/header/index.ts @@ -2,9 +2,10 @@ // See LICENSE.txt for license information. import withObservables from '@nozbe/with-observables'; +import {combineLatestWith} from 'rxjs'; import {switchMap} from 'rxjs/operators'; -import {observeConfigBooleanValue} from '@queries/servers/system'; +import {observeConfigBooleanValue, observeCurrentChannelId} from '@queries/servers/system'; import CategoryHeader from './header'; @@ -12,11 +13,13 @@ import type CategoryModel from '@typings/database/models/servers/category'; const enhanced = withObservables(['category'], ({category}: {category: CategoryModel}) => { const canViewArchived = observeConfigBooleanValue(category.database, 'ExperimentalViewArchivedChannels'); + const currentChannelId = observeCurrentChannelId(category.database); return { category, hasChannels: canViewArchived.pipe( - switchMap((canView) => category.observeHasChannels(canView)), + combineLatestWith(currentChannelId), + switchMap(([canView, channelId]) => category.observeHasChannels(canView, channelId)), ), }; }); diff --git a/types/database/models/servers/category.ts b/types/database/models/servers/category.ts index 2b529fe816..1206c15875 100644 --- a/types/database/models/servers/category.ts +++ b/types/database/models/servers/category.ts @@ -58,7 +58,7 @@ declare class CategoryModel extends Model { @lazy myChannels: Query; /** hasChannels : Whether the category has any channels */ - observeHasChannels(canViewArchived: boolean): Observable; + observeHasChannels(canViewArchived: boolean, channelId: string): Observable; /** toCategoryWithChannels returns a map of the Category with an array of ordered channel ids */ toCategoryWithChannels(): Promise;