diff --git a/src/components/left/main/ChatFolders.tsx b/src/components/left/main/ChatFolders.tsx index 28dcd6023..949fd103f 100644 --- a/src/components/left/main/ChatFolders.tsx +++ b/src/components/left/main/ChatFolders.tsx @@ -27,7 +27,7 @@ type StateProps = { usersById: Record; chatFoldersById: Record; notifySettings: NotifySettings; - notifyExceptions: Record; + notifyExceptions?: Record; orderedFolderIds?: number[]; lastSyncTime?: number; }; @@ -74,7 +74,7 @@ const ChatFolders: FC = ({ const counters = displayedFolders.map((folder) => { const { unreadDialogsCount, hasActiveDialogs, - } = getFolderUnreadDialogs(chatsById, usersById, folder, notifySettings, notifyExceptions, chatIds) || {}; + } = getFolderUnreadDialogs(chatsById, usersById, folder, chatIds, notifySettings, notifyExceptions) || {}; return { id: folder.id, diff --git a/src/components/left/main/ChatList.tsx b/src/components/left/main/ChatList.tsx index 77e123513..1ec952503 100644 --- a/src/components/left/main/ChatList.tsx +++ b/src/components/left/main/ChatList.tsx @@ -40,7 +40,7 @@ type StateProps = { lastSyncTime?: number; isInDiscussionThread?: boolean; notifySettings: NotifySettings; - notifyExceptions: Record; + notifyExceptions?: Record; }; type DispatchProps = Pick; diff --git a/src/components/left/settings/folders/SettingsFoldersMain.tsx b/src/components/left/settings/folders/SettingsFoldersMain.tsx index 189563e42..bf6ed38db 100644 --- a/src/components/left/settings/folders/SettingsFoldersMain.tsx +++ b/src/components/left/settings/folders/SettingsFoldersMain.tsx @@ -32,7 +32,7 @@ type StateProps = { foldersById: Record; recommendedChatFolders?: ApiChatFolder[]; notifySettings: NotifySettings; - notifyExceptions: Record; + notifyExceptions?: Record; }; type DispatchProps = Pick; @@ -103,7 +103,7 @@ const SettingsFoldersMain: FC = ({ id: folder.id, title: folder.title, subtitle: getFolderDescriptionText( - chatsById, usersById, folder, notifySettings, notifyExceptions, chatIds, lang, + chatsById, usersById, folder, chatIds, lang, notifySettings, notifyExceptions, ), }; }); diff --git a/src/global/types.ts b/src/global/types.ts index d38977f01..a6fc2720d 100644 --- a/src/global/types.ts +++ b/src/global/types.ts @@ -366,7 +366,7 @@ export type GlobalState = { byKey: ISettings; loadedWallpapers?: ApiWallpaper[]; privacy: Partial>; - notifyExceptions: Record; + notifyExceptions?: Record; }; twoFaSettings: { diff --git a/src/modules/helpers/chats.ts b/src/modules/helpers/chats.ts index e482ff0f1..5cf67aa04 100644 --- a/src/modules/helpers/chats.ts +++ b/src/modules/helpers/chats.ts @@ -202,9 +202,9 @@ export function isChatArchived(chat: ApiChat) { } export function selectIsChatMuted( - chat: ApiChat, notifySettings: NotifySettings, notifyExceptions: Record, + chat: ApiChat, notifySettings: NotifySettings, notifyExceptions?: Record, ) { - return !(notifyExceptions[chat.id] && !notifyExceptions[chat.id].isMuted) && ( + return !(notifyExceptions && notifyExceptions[chat.id] && !notifyExceptions[chat.id].isMuted) && ( chat.isMuted || (isChatPrivate(chat.id) && !notifySettings.hasPrivateChatsNotifications) || (isChatChannel(chat) && !notifySettings.hasBroadcastNotifications) @@ -221,7 +221,7 @@ export function prepareFolderListIds( usersById: Record, folder: ApiChatFolder, notifySettings: NotifySettings, - notifyExceptions: Record, + notifyExceptions?: Record, chatIdsCache?: number[], ) { const excludedChatIds = folder.excludedChatIds ? new Set(folder.excludedChatIds) : undefined; @@ -249,7 +249,7 @@ function filterChatFolder( folder: ApiChatFolder, usersById: Record, notifySettings: NotifySettings, - notifyExceptions: Record, + notifyExceptions?: Record, excludedChatIds?: Set, includedChatIds?: Set, pinnedChatIds?: Set, @@ -363,9 +363,9 @@ export function getFolderUnreadDialogs( chatsById: Record, usersById: Record, folder: ApiChatFolder, - notifySettings: NotifySettings, - notifyExceptions: Record, chatIdsCache: number[], + notifySettings: NotifySettings, + notifyExceptions?: Record, ) { const [listIds] = prepareFolderListIds(chatsById, usersById, folder, notifySettings, notifyExceptions, chatIdsCache); @@ -391,10 +391,10 @@ export function getFolderDescriptionText( chatsById: Record, usersById: Record, folder: ApiChatFolder, - notifySettings: NotifySettings, - notifyExceptions: Record, chatIdsCache: number[], lang: LangFn, + notifySettings: NotifySettings, + notifyExceptions?: Record, ) { const { id, title, emoticon, description, pinnedChatIds, @@ -410,7 +410,7 @@ export function getFolderDescriptionText( || (excludedChatIds && excludedChatIds.length) || (includedChatIds && includedChatIds.length) ) { - const length = getFolderChatsCount(chatsById, usersById, folder, notifySettings, notifyExceptions, chatIdsCache); + const length = getFolderChatsCount(chatsById, usersById, folder, chatIdsCache, notifySettings, notifyExceptions); return lang('Chats', length); } @@ -434,9 +434,9 @@ function getFolderChatsCount( chatsById: Record, usersById: Record, folder: ApiChatFolder, - notifySettings: NotifySettings, - notifyExceptions: Record, chatIdsCache: number[], + notifySettings: NotifySettings, + notifyExceptions?: Record, ) { const [listIds, pinnedIds] = prepareFolderListIds( chatsById, usersById, folder, notifySettings, notifyExceptions, chatIdsCache,