mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
left_sidebar: Include unmuted counts in muted channels in toggle count.
This commit is contained in:
@@ -664,9 +664,12 @@ type SectionUnreadCount = {
|
||||
// These both include inactive unreads as well.
|
||||
unmuted: number;
|
||||
muted: number;
|
||||
// These are used for the "+ n inactive channels" button.
|
||||
// These are used for the count on the inactive/muted channel toggle.
|
||||
inactive_unmuted: number;
|
||||
inactive_muted: number;
|
||||
// e.g. followed topics in a muted channel, which count towards
|
||||
// the unmuted count in the inactive/muted channels toggle.
|
||||
muted_channel_unmuted: number;
|
||||
};
|
||||
|
||||
export let update_dom_with_unread_counts = function (counts: FullUnreadCountsData): void {
|
||||
@@ -700,6 +703,7 @@ export let update_dom_with_unread_counts = function (counts: FullUnreadCountsDat
|
||||
// Not used for the pinned section, but included here to make typing easier
|
||||
inactive_unmuted: 0,
|
||||
inactive_muted: 0,
|
||||
muted_channel_unmuted: 0,
|
||||
};
|
||||
const folder_unread_counts = new Map<number, SectionUnreadCount>();
|
||||
const normal_section_unread_counts: SectionUnreadCount = {
|
||||
@@ -707,6 +711,7 @@ export let update_dom_with_unread_counts = function (counts: FullUnreadCountsDat
|
||||
muted: 0,
|
||||
inactive_unmuted: 0,
|
||||
inactive_muted: 0,
|
||||
muted_channel_unmuted: 0,
|
||||
};
|
||||
|
||||
for (const [stream_id, stream_count_info] of counts.stream_count.entries()) {
|
||||
@@ -722,12 +727,16 @@ export let update_dom_with_unread_counts = function (counts: FullUnreadCountsDat
|
||||
muted: 0,
|
||||
inactive_unmuted: 0,
|
||||
inactive_muted: 0,
|
||||
muted_channel_unmuted: 0,
|
||||
});
|
||||
}
|
||||
|
||||
const unread_counts = folder_unread_counts.get(sub.folder_id)!;
|
||||
unread_counts.unmuted += stream_count_info.unmuted_count;
|
||||
unread_counts.muted += stream_count_info.muted_count;
|
||||
if (sub.is_muted) {
|
||||
unread_counts.muted_channel_unmuted += stream_count_info.unmuted_count;
|
||||
}
|
||||
if (!stream_list_sort.has_recent_activity(sub)) {
|
||||
unread_counts.inactive_unmuted += stream_count_info.unmuted_count;
|
||||
unread_counts.inactive_muted += stream_count_info.muted_count;
|
||||
@@ -735,6 +744,10 @@ export let update_dom_with_unread_counts = function (counts: FullUnreadCountsDat
|
||||
} else {
|
||||
normal_section_unread_counts.unmuted += stream_count_info.unmuted_count;
|
||||
normal_section_unread_counts.muted += stream_count_info.muted_count;
|
||||
if (sub.is_muted) {
|
||||
normal_section_unread_counts.muted_channel_unmuted +=
|
||||
stream_count_info.unmuted_count;
|
||||
}
|
||||
if (!stream_list_sort.has_recent_activity(sub)) {
|
||||
normal_section_unread_counts.inactive_unmuted += stream_count_info.unmuted_count;
|
||||
normal_section_unread_counts.inactive_muted += stream_count_info.muted_count;
|
||||
@@ -773,7 +786,8 @@ export let update_dom_with_unread_counts = function (counts: FullUnreadCountsDat
|
||||
);
|
||||
update_section_unread_count(
|
||||
$("#stream-list-normal-streams-container .show-inactive-or-muted-channels"),
|
||||
normal_section_unread_counts.inactive_unmuted,
|
||||
normal_section_unread_counts.inactive_unmuted +
|
||||
normal_section_unread_counts.muted_channel_unmuted,
|
||||
normal_section_unread_counts.inactive_muted + normal_section_unread_counts.muted,
|
||||
);
|
||||
|
||||
@@ -783,6 +797,7 @@ export let update_dom_with_unread_counts = function (counts: FullUnreadCountsDat
|
||||
muted: 0,
|
||||
inactive_unmuted: 0,
|
||||
inactive_muted: 0,
|
||||
muted_channel_unmuted: 0,
|
||||
};
|
||||
update_section_unread_count(
|
||||
$(`#stream-list-${folder_id}-container .stream-list-subsection-header`),
|
||||
@@ -791,7 +806,7 @@ export let update_dom_with_unread_counts = function (counts: FullUnreadCountsDat
|
||||
);
|
||||
update_section_unread_count(
|
||||
$(`#stream-list-${folder_id}-container .show-inactive-or-muted-channels`),
|
||||
unread_counts.inactive_unmuted,
|
||||
unread_counts.inactive_unmuted + unread_counts.muted_channel_unmuted,
|
||||
unread_counts.inactive_muted + unread_counts.muted,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user