fix(app): inherit category mute when hiding muted channels (#2558)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-06 22:10:09 +02:00
1 parent 2fd5daf104
commit 00c1b19809
3 files changed
+51 -12

No files matched your search

@@ -362,15 +362,21 @@ 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 =
hideMutedChannels && group.category
? UserGuildSettings.isChannelDirectlyMuted(guild.id, group.category.id)
: false;
let filteredTextChannels: Array<Channel>;
let filteredVoiceChannels: Array<Channel>;
if (hideMutedChannels) {
filteredTextChannels = [];
for (const ch of group.textChannels) {
const isMuted = UserGuildSettings.isChannelDirectlyMuted(guild.id, ch.id);
const isChannelMuted = UserGuildSettings.isChannelDirectlyMuted(guild.id, ch.id);
const isMuted = isCategoryMuted || isChannelMuted;
if (
shouldShowChannelWhenHidingMutedChannels({
isMuted,
isCategoryMuted,
isChannelMuted,
isSelected: ch.id === selectedChannelInGuildId,
isConnected: false,
hasVisibleUnread: isMuted && hasVisibleUnreadInChannel(ch.id),
@@ -381,10 +387,12 @@ export const ChannelListContent = observer(({guild, scrollY}: {guild: Guild; scr
}
filteredVoiceChannels = [];
for (const ch of group.voiceChannels) {
const isMuted = UserGuildSettings.isChannelDirectlyMuted(guild.id, ch.id);
const isChannelMuted = UserGuildSettings.isChannelDirectlyMuted(guild.id, ch.id);
const isMuted = isCategoryMuted || isChannelMuted;
if (
shouldShowChannelWhenHidingMutedChannels({
isMuted,
isCategoryMuted,
isChannelMuted,
isSelected: ch.id === selectedChannelInGuildId,
isConnected: ch.id === connectedChannelId,
hasVisibleUnread: isMuted && hasVisibleUnreadInChannel(ch.id),
@@ -11,7 +11,8 @@ describe('shouldShowChannelWhenHidingMutedChannels', () => {
it('keeps muted channels with visible unread state so mentions are findable', () => {
expect(
shouldShowChannelWhenHidingMutedChannels({
isMuted: true,
isCategoryMuted: false,
isChannelMuted: true,
isSelected: false,
isConnected: false,
hasVisibleUnread: true,
@@ -22,7 +23,8 @@ describe('shouldShowChannelWhenHidingMutedChannels', () => {
it('hides muted channels without visible unread state', () => {
expect(
shouldShowChannelWhenHidingMutedChannels({
isMuted: true,
isCategoryMuted: false,
isChannelMuted: true,
isSelected: false,
isConnected: false,
hasVisibleUnread: false,
@@ -30,10 +32,35 @@ describe('shouldShowChannelWhenHidingMutedChannels', () => {
).toBe(false);
});
it('inherits the mute from a muted category', () => {
expect(
shouldShowChannelWhenHidingMutedChannels({
isCategoryMuted: true,
isChannelMuted: false,
isSelected: false,
isConnected: false,
hasVisibleUnread: false,
}),
).toBe(false);
});
it('keeps channels of a muted category that have visible unread state', () => {
expect(
shouldShowChannelWhenHidingMutedChannels({
isCategoryMuted: true,
isChannelMuted: false,
isSelected: false,
isConnected: false,
hasVisibleUnread: true,
}),
).toBe(true);
});
it('keeps selected and connected muted channels visible', () => {
expect(
shouldShowChannelWhenHidingMutedChannels({
isMuted: true,
isCategoryMuted: true,
isChannelMuted: true,
isSelected: true,
isConnected: false,
hasVisibleUnread: false,
@@ -41,7 +68,8 @@ describe('shouldShowChannelWhenHidingMutedChannels', () => {
).toBe(true);
expect(
shouldShowChannelWhenHidingMutedChannels({
isMuted: true,
isCategoryMuted: true,
isChannelMuted: false,
isSelected: false,
isConnected: true,
hasVisibleUnread: false,
@@ -52,7 +80,8 @@ describe('shouldShowChannelWhenHidingMutedChannels', () => {
it('keeps unmuted channels visible', () => {
expect(
shouldShowChannelWhenHidingMutedChannels({
isMuted: false,
isCategoryMuted: false,
isChannelMuted: false,
isSelected: false,
isConnected: false,
hasVisibleUnread: false,
@@ -1,19 +1,21 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
export interface HiddenMutedChannelVisibilityInput {
isMuted: boolean;
isCategoryMuted: boolean;
isChannelMuted: boolean;
isSelected: boolean;
isConnected: boolean;
hasVisibleUnread: boolean;
}
export function shouldShowChannelWhenHidingMutedChannels({
isMuted,
isCategoryMuted,
isChannelMuted,
isSelected,
isConnected,
hasVisibleUnread,
}: HiddenMutedChannelVisibilityInput): boolean {
return isSelected || isConnected || !isMuted || hasVisibleUnread;
return isSelected || isConnected || !(isCategoryMuted || isChannelMuted) || hasVisibleUnread;
}
export interface HiddenMutedCategoryVisibilityInput {