Notification Profiles: Exclude silenced conversations from badge count

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal
2025-10-29 15:20:47 -05:00
committed by GitHub
parent 57d61f93e3
commit fa2b952286
3 changed files with 22 additions and 5 deletions

View File

@@ -371,10 +371,18 @@ export class ConversationController {
const badgeCountMutedConversationsSetting =
itemStorage.get('badge-count-muted-conversations') || false;
const { activeProfile } = window.reduxStore.getState().notificationProfiles;
const unreadStats = countAllConversationsUnreadStats(
this.#_conversations.map(
(conversation): ConversationPropsForUnreadStats => {
(conversation): ConversationPropsForUnreadStats | undefined => {
if (
activeProfile &&
!activeProfile.allowedMembers.has(conversation.id)
) {
return undefined;
}
// Need to pull this out manually into the Redux shape
// because `conversation.format()` can return cached props by the
// time this runs

View File

@@ -164,11 +164,20 @@ export class NotificationProfilesService {
)
: undefined;
if (!isEqual(previousCurrentState, currentState)) {
if (
!isEqual(previousCurrentState, currentState) ||
!isEqual(currentActiveProfile, previousActiveProfile)
) {
const idForLogging = currentActiveProfile
? redactNotificationProfileId(currentActiveProfile.id)
: 'NONE';
log.info(
'notificationProfileService: next profile event has changed, updating redux'
`notificationProfileService: next profile event has changed, updating redux. Active profile is ${idForLogging}`
);
updateCurrentState(currentState, currentActiveProfile);
// The active profile can influence the overall badge count
window.ConversationController.updateUnreadCount();
}
if (previousActiveProfile?.id === currentActiveProfileId) {

View File

@@ -157,13 +157,13 @@ export function countConversationUnreadStats(
}
export function countAllConversationsUnreadStats(
conversations: ReadonlyArray<ConversationPropsForUnreadStats>,
conversations: ReadonlyArray<ConversationPropsForUnreadStats | undefined>,
options: UnreadStatsOptions
): UnreadStats {
const unreadStats = _createUnreadStats();
for (const conversation of conversations) {
if (_canCountConversation(conversation, options)) {
if (conversation && _canCountConversation(conversation, options)) {
_countConversation(unreadStats, conversation);
}
}