mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
fix(app): show empty categories when hiding muted channels (#2460)
This commit is contained in:
1 parent
18ae2e563e
commit
1e6c332eae
3 files changed
+51
-3
No files matched your search
@@ -16,6 +16,7 @@ import {NullSpaceDropIndicator} from '@app/features/app/components/layout/NullSp
|
|||||||
import {ScrollIndicatorOverlay} from '@app/features/app/components/layout/ScrollIndicatorOverlay';
|
import {ScrollIndicatorOverlay} from '@app/features/app/components/layout/ScrollIndicatorOverlay';
|
||||||
import {type DragItem, DragItemType, type DropResult} from '@app/features/app/components/layout/types/DndTypes';
|
import {type DragItem, DragItemType, type DropResult} from '@app/features/app/components/layout/types/DndTypes';
|
||||||
import {
|
import {
|
||||||
|
shouldShowCategoryWhenHidingMutedChannels,
|
||||||
shouldShowChannelInCollapsedCategory,
|
shouldShowChannelInCollapsedCategory,
|
||||||
shouldShowChannelWhenHidingMutedChannels,
|
shouldShowChannelWhenHidingMutedChannels,
|
||||||
} from '@app/features/app/components/layout/utils/ChannelListVisibility';
|
} from '@app/features/app/components/layout/utils/ChannelListVisibility';
|
||||||
@@ -471,8 +472,10 @@ export const ChannelListContent = observer(({guild, scrollY}: {guild: Guild; scr
|
|||||||
if (
|
if (
|
||||||
hideMutedChannels &&
|
hideMutedChannels &&
|
||||||
group.category &&
|
group.category &&
|
||||||
filteredTextChannels.length === 0 &&
|
!shouldShowCategoryWhenHidingMutedChannels({
|
||||||
filteredVoiceChannels.length === 0
|
hasChannels: group.textChannels.length > 0 || group.voiceChannels.length > 0,
|
||||||
|
hasVisibleChannels: filteredTextChannels.length > 0 || filteredVoiceChannels.length > 0,
|
||||||
|
})
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
import {describe, expect, it} from 'vitest';
|
import {describe, expect, it} from 'vitest';
|
||||||
import {shouldShowChannelInCollapsedCategory, shouldShowChannelWhenHidingMutedChannels} from './ChannelListVisibility';
|
import {
|
||||||
|
shouldShowCategoryWhenHidingMutedChannels,
|
||||||
|
shouldShowChannelInCollapsedCategory,
|
||||||
|
shouldShowChannelWhenHidingMutedChannels,
|
||||||
|
} from './ChannelListVisibility';
|
||||||
|
|
||||||
describe('shouldShowChannelWhenHidingMutedChannels', () => {
|
describe('shouldShowChannelWhenHidingMutedChannels', () => {
|
||||||
it('keeps muted channels with visible unread state so mentions are findable', () => {
|
it('keeps muted channels with visible unread state so mentions are findable', () => {
|
||||||
@@ -57,6 +61,35 @@ describe('shouldShowChannelWhenHidingMutedChannels', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('shouldShowCategoryWhenHidingMutedChannels', () => {
|
||||||
|
it('keeps a category that has no channels at all', () => {
|
||||||
|
expect(
|
||||||
|
shouldShowCategoryWhenHidingMutedChannels({
|
||||||
|
hasChannels: false,
|
||||||
|
hasVisibleChannels: false,
|
||||||
|
}),
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hides a category whose channels were all filtered out as muted', () => {
|
||||||
|
expect(
|
||||||
|
shouldShowCategoryWhenHidingMutedChannels({
|
||||||
|
hasChannels: true,
|
||||||
|
hasVisibleChannels: false,
|
||||||
|
}),
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('keeps a category that still has visible channels', () => {
|
||||||
|
expect(
|
||||||
|
shouldShowCategoryWhenHidingMutedChannels({
|
||||||
|
hasChannels: true,
|
||||||
|
hasVisibleChannels: true,
|
||||||
|
}),
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('shouldShowChannelInCollapsedCategory', () => {
|
describe('shouldShowChannelInCollapsedCategory', () => {
|
||||||
it('keeps visible unread channels reachable in collapsed categories', () => {
|
it('keeps visible unread channels reachable in collapsed categories', () => {
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -16,6 +16,18 @@ export function shouldShowChannelWhenHidingMutedChannels({
|
|||||||
return isSelected || isConnected || !isMuted || hasVisibleUnread;
|
return isSelected || isConnected || !isMuted || hasVisibleUnread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface HiddenMutedCategoryVisibilityInput {
|
||||||
|
hasChannels: boolean;
|
||||||
|
hasVisibleChannels: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function shouldShowCategoryWhenHidingMutedChannels({
|
||||||
|
hasChannels,
|
||||||
|
hasVisibleChannels,
|
||||||
|
}: HiddenMutedCategoryVisibilityInput): boolean {
|
||||||
|
return !hasChannels || hasVisibleChannels;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CollapsedCategoryChannelVisibilityInput {
|
export interface CollapsedCategoryChannelVisibilityInput {
|
||||||
isCategoryMuted: boolean;
|
isCategoryMuted: boolean;
|
||||||
isSelected: boolean;
|
isSelected: boolean;
|
||||||
|
|||||||
Reference in new issue
Block a user