mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 02:08:57 +00:00
Notification Profiles: Exclude silenced conversations from badge count
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user