fix(app): show unread channels in muted collapsed categories (#2555)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-06 20:45:11 +02:00
1 parent 0f24cfb6ef
commit d91b5bec66
3 files changed
+26 -21

No files matched your search

@@ -338,9 +338,7 @@ export const ChannelListContent = observer(({guild, scrollY}: {guild: Guild; scr
const unreadCount = ReadStates.getUnreadCount(channelId);
const hasUnread = ReadStates.hasUnread(channelId);
const mentionCount = ReadStates.getMentionCount(channelId);
const isMuted =
UserGuildSettings.isParentCategoryMuted(guild.id, channelId) ||
UserGuildSettings.isChannelDirectlyMuted(guild.id, channelId);
const isMuted = UserGuildSettings.isChannelDirectlyMuted(guild.id, channelId);
const channel = Channels.getChannel(channelId);
const unreadBadgesLevel = channel
? UserGuildSettings.resolvedUnreadBadgesLevel({
@@ -364,9 +362,6 @@ export const ChannelListContent = observer(({guild, scrollY}: {guild: Guild; scr
for (const group of channelGroups) {
const isCollapsed = group.category ? (collapsedCategories?.has(group.category.id) ?? false) : false;
const isNullSpace = !group.category;
const isCategoryMuted = group.category
? UserGuildSettings.isChannelDirectlyMuted(guild.id, group.category.id)
: false;
let filteredTextChannels: Array<Channel>;
let filteredVoiceChannels: Array<Channel>;
if (hideMutedChannels) {
@@ -411,8 +406,8 @@ export const ChannelListContent = observer(({guild, scrollY}: {guild: Guild; scr
for (const ch of filteredTextChannels) {
if (
shouldShowChannelInCollapsedCategory({
isCategoryMuted,
isSelected: ch.id === showTextSelected,
isConnected: false,
hasVisibleUnread: hasVisibleUnreadInChannel(ch.id),
})
) {
@@ -442,8 +437,8 @@ export const ChannelListContent = observer(({guild, scrollY}: {guild: Guild; scr
for (const ch of filteredVoiceChannels) {
if (
shouldShowChannelInCollapsedCategory({
isCategoryMuted,
isSelected: ch.id === selectedChannelInGuildId,
isConnected: ch.id === connectedChannelId,
hasVisibleUnread: hasVisibleUnreadInChannel(ch.id),
})
) {
@@ -94,27 +94,37 @@ describe('shouldShowChannelInCollapsedCategory', () => {
it('keeps visible unread channels reachable in collapsed categories', () => {
expect(
shouldShowChannelInCollapsedCategory({
isCategoryMuted: false,
isSelected: false,
isConnected: false,
hasVisibleUnread: true,
}),
).toBe(true);
});
it('does not reveal unread channels from muted collapsed categories unless selected', () => {
it('keeps selected and connected channels visible without unread state', () => {
expect(
shouldShowChannelInCollapsedCategory({
isCategoryMuted: true,
isSelected: false,
hasVisibleUnread: true,
}),
).toBe(false);
expect(
shouldShowChannelInCollapsedCategory({
isCategoryMuted: true,
isSelected: true,
isConnected: false,
hasVisibleUnread: false,
}),
).toBe(true);
expect(
shouldShowChannelInCollapsedCategory({
isSelected: false,
isConnected: true,
hasVisibleUnread: false,
}),
).toBe(true);
});
it('hides read channels in collapsed categories', () => {
expect(
shouldShowChannelInCollapsedCategory({
isSelected: false,
isConnected: false,
hasVisibleUnread: false,
}),
).toBe(false);
});
});
@@ -29,15 +29,15 @@ export function shouldShowCategoryWhenHidingMutedChannels({
}
export interface CollapsedCategoryChannelVisibilityInput {
isCategoryMuted: boolean;
isSelected: boolean;
isConnected: boolean;
hasVisibleUnread: boolean;
}
export function shouldShowChannelInCollapsedCategory({
isCategoryMuted,
isSelected,
isConnected,
hasVisibleUnread,
}: CollapsedCategoryChannelVisibilityInput): boolean {
return isSelected || (!isCategoryMuted && hasVisibleUnread);
return isSelected || isConnected || hasVisibleUnread;
}