mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
fix(app): show unread channels in muted collapsed categories (#2555)
This commit is contained in:
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 unreadCount = ReadStates.getUnreadCount(channelId);
|
||||||
const hasUnread = ReadStates.hasUnread(channelId);
|
const hasUnread = ReadStates.hasUnread(channelId);
|
||||||
const mentionCount = ReadStates.getMentionCount(channelId);
|
const mentionCount = ReadStates.getMentionCount(channelId);
|
||||||
const isMuted =
|
const isMuted = UserGuildSettings.isChannelDirectlyMuted(guild.id, channelId);
|
||||||
UserGuildSettings.isParentCategoryMuted(guild.id, channelId) ||
|
|
||||||
UserGuildSettings.isChannelDirectlyMuted(guild.id, channelId);
|
|
||||||
const channel = Channels.getChannel(channelId);
|
const channel = Channels.getChannel(channelId);
|
||||||
const unreadBadgesLevel = channel
|
const unreadBadgesLevel = channel
|
||||||
? UserGuildSettings.resolvedUnreadBadgesLevel({
|
? UserGuildSettings.resolvedUnreadBadgesLevel({
|
||||||
@@ -364,9 +362,6 @@ export const ChannelListContent = observer(({guild, scrollY}: {guild: Guild; scr
|
|||||||
for (const group of channelGroups) {
|
for (const group of channelGroups) {
|
||||||
const isCollapsed = group.category ? (collapsedCategories?.has(group.category.id) ?? false) : false;
|
const isCollapsed = group.category ? (collapsedCategories?.has(group.category.id) ?? false) : false;
|
||||||
const isNullSpace = !group.category;
|
const isNullSpace = !group.category;
|
||||||
const isCategoryMuted = group.category
|
|
||||||
? UserGuildSettings.isChannelDirectlyMuted(guild.id, group.category.id)
|
|
||||||
: false;
|
|
||||||
let filteredTextChannels: Array<Channel>;
|
let filteredTextChannels: Array<Channel>;
|
||||||
let filteredVoiceChannels: Array<Channel>;
|
let filteredVoiceChannels: Array<Channel>;
|
||||||
if (hideMutedChannels) {
|
if (hideMutedChannels) {
|
||||||
@@ -411,8 +406,8 @@ export const ChannelListContent = observer(({guild, scrollY}: {guild: Guild; scr
|
|||||||
for (const ch of filteredTextChannels) {
|
for (const ch of filteredTextChannels) {
|
||||||
if (
|
if (
|
||||||
shouldShowChannelInCollapsedCategory({
|
shouldShowChannelInCollapsedCategory({
|
||||||
isCategoryMuted,
|
|
||||||
isSelected: ch.id === showTextSelected,
|
isSelected: ch.id === showTextSelected,
|
||||||
|
isConnected: false,
|
||||||
hasVisibleUnread: hasVisibleUnreadInChannel(ch.id),
|
hasVisibleUnread: hasVisibleUnreadInChannel(ch.id),
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
@@ -442,8 +437,8 @@ export const ChannelListContent = observer(({guild, scrollY}: {guild: Guild; scr
|
|||||||
for (const ch of filteredVoiceChannels) {
|
for (const ch of filteredVoiceChannels) {
|
||||||
if (
|
if (
|
||||||
shouldShowChannelInCollapsedCategory({
|
shouldShowChannelInCollapsedCategory({
|
||||||
isCategoryMuted,
|
|
||||||
isSelected: ch.id === selectedChannelInGuildId,
|
isSelected: ch.id === selectedChannelInGuildId,
|
||||||
|
isConnected: ch.id === connectedChannelId,
|
||||||
hasVisibleUnread: hasVisibleUnreadInChannel(ch.id),
|
hasVisibleUnread: hasVisibleUnreadInChannel(ch.id),
|
||||||
})
|
})
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -94,27 +94,37 @@ describe('shouldShowChannelInCollapsedCategory', () => {
|
|||||||
it('keeps visible unread channels reachable in collapsed categories', () => {
|
it('keeps visible unread channels reachable in collapsed categories', () => {
|
||||||
expect(
|
expect(
|
||||||
shouldShowChannelInCollapsedCategory({
|
shouldShowChannelInCollapsedCategory({
|
||||||
isCategoryMuted: false,
|
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
|
isConnected: false,
|
||||||
hasVisibleUnread: true,
|
hasVisibleUnread: true,
|
||||||
}),
|
}),
|
||||||
).toBe(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(
|
expect(
|
||||||
shouldShowChannelInCollapsedCategory({
|
shouldShowChannelInCollapsedCategory({
|
||||||
isCategoryMuted: true,
|
|
||||||
isSelected: false,
|
|
||||||
hasVisibleUnread: true,
|
|
||||||
}),
|
|
||||||
).toBe(false);
|
|
||||||
expect(
|
|
||||||
shouldShowChannelInCollapsedCategory({
|
|
||||||
isCategoryMuted: true,
|
|
||||||
isSelected: true,
|
isSelected: true,
|
||||||
|
isConnected: false,
|
||||||
|
hasVisibleUnread: false,
|
||||||
|
}),
|
||||||
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
shouldShowChannelInCollapsedCategory({
|
||||||
|
isSelected: false,
|
||||||
|
isConnected: true,
|
||||||
hasVisibleUnread: false,
|
hasVisibleUnread: false,
|
||||||
}),
|
}),
|
||||||
).toBe(true);
|
).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 {
|
export interface CollapsedCategoryChannelVisibilityInput {
|
||||||
isCategoryMuted: boolean;
|
|
||||||
isSelected: boolean;
|
isSelected: boolean;
|
||||||
|
isConnected: boolean;
|
||||||
hasVisibleUnread: boolean;
|
hasVisibleUnread: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function shouldShowChannelInCollapsedCategory({
|
export function shouldShowChannelInCollapsedCategory({
|
||||||
isCategoryMuted,
|
|
||||||
isSelected,
|
isSelected,
|
||||||
|
isConnected,
|
||||||
hasVisibleUnread,
|
hasVisibleUnread,
|
||||||
}: CollapsedCategoryChannelVisibilityInput): boolean {
|
}: CollapsedCategoryChannelVisibilityInput): boolean {
|
||||||
return isSelected || (!isCategoryMuted && hasVisibleUnread);
|
return isSelected || isConnected || hasVisibleUnread;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user