Fix backwards compatibility (#1131)

This commit is contained in:
Alexander Zinchuk 2021-06-01 11:49:27 +03:00
parent 3106d9099e
commit c2c3832908
5 changed files with 17 additions and 17 deletions

View File

@ -27,7 +27,7 @@ type StateProps = {
usersById: Record<number, ApiUser>; usersById: Record<number, ApiUser>;
chatFoldersById: Record<number, ApiChatFolder>; chatFoldersById: Record<number, ApiChatFolder>;
notifySettings: NotifySettings; notifySettings: NotifySettings;
notifyExceptions: Record<number, NotifyException>; notifyExceptions?: Record<number, NotifyException>;
orderedFolderIds?: number[]; orderedFolderIds?: number[];
lastSyncTime?: number; lastSyncTime?: number;
}; };
@ -74,7 +74,7 @@ const ChatFolders: FC<StateProps & DispatchProps> = ({
const counters = displayedFolders.map((folder) => { const counters = displayedFolders.map((folder) => {
const { const {
unreadDialogsCount, hasActiveDialogs, unreadDialogsCount, hasActiveDialogs,
} = getFolderUnreadDialogs(chatsById, usersById, folder, notifySettings, notifyExceptions, chatIds) || {}; } = getFolderUnreadDialogs(chatsById, usersById, folder, chatIds, notifySettings, notifyExceptions) || {};
return { return {
id: folder.id, id: folder.id,

View File

@ -40,7 +40,7 @@ type StateProps = {
lastSyncTime?: number; lastSyncTime?: number;
isInDiscussionThread?: boolean; isInDiscussionThread?: boolean;
notifySettings: NotifySettings; notifySettings: NotifySettings;
notifyExceptions: Record<number, NotifyException>; notifyExceptions?: Record<number, NotifyException>;
}; };
type DispatchProps = Pick<GlobalActions, 'loadMoreChats' | 'preloadTopChatMessages'>; type DispatchProps = Pick<GlobalActions, 'loadMoreChats' | 'preloadTopChatMessages'>;

View File

@ -32,7 +32,7 @@ type StateProps = {
foldersById: Record<number, ApiChatFolder>; foldersById: Record<number, ApiChatFolder>;
recommendedChatFolders?: ApiChatFolder[]; recommendedChatFolders?: ApiChatFolder[];
notifySettings: NotifySettings; notifySettings: NotifySettings;
notifyExceptions: Record<number, NotifyException>; notifyExceptions?: Record<number, NotifyException>;
}; };
type DispatchProps = Pick<GlobalActions, 'loadRecommendedChatFolders' | 'addChatFolder' | 'showError'>; type DispatchProps = Pick<GlobalActions, 'loadRecommendedChatFolders' | 'addChatFolder' | 'showError'>;
@ -103,7 +103,7 @@ const SettingsFoldersMain: FC<OwnProps & StateProps & DispatchProps> = ({
id: folder.id, id: folder.id,
title: folder.title, title: folder.title,
subtitle: getFolderDescriptionText( subtitle: getFolderDescriptionText(
chatsById, usersById, folder, notifySettings, notifyExceptions, chatIds, lang, chatsById, usersById, folder, chatIds, lang, notifySettings, notifyExceptions,
), ),
}; };
}); });

View File

@ -366,7 +366,7 @@ export type GlobalState = {
byKey: ISettings; byKey: ISettings;
loadedWallpapers?: ApiWallpaper[]; loadedWallpapers?: ApiWallpaper[];
privacy: Partial<Record<ApiPrivacyKey, ApiPrivacySettings>>; privacy: Partial<Record<ApiPrivacyKey, ApiPrivacySettings>>;
notifyExceptions: Record<number, NotifyException>; notifyExceptions?: Record<number, NotifyException>;
}; };
twoFaSettings: { twoFaSettings: {

View File

@ -202,9 +202,9 @@ export function isChatArchived(chat: ApiChat) {
} }
export function selectIsChatMuted( export function selectIsChatMuted(
chat: ApiChat, notifySettings: NotifySettings, notifyExceptions: Record<number, NotifyException>, chat: ApiChat, notifySettings: NotifySettings, notifyExceptions?: Record<number, NotifyException>,
) { ) {
return !(notifyExceptions[chat.id] && !notifyExceptions[chat.id].isMuted) && ( return !(notifyExceptions && notifyExceptions[chat.id] && !notifyExceptions[chat.id].isMuted) && (
chat.isMuted chat.isMuted
|| (isChatPrivate(chat.id) && !notifySettings.hasPrivateChatsNotifications) || (isChatPrivate(chat.id) && !notifySettings.hasPrivateChatsNotifications)
|| (isChatChannel(chat) && !notifySettings.hasBroadcastNotifications) || (isChatChannel(chat) && !notifySettings.hasBroadcastNotifications)
@ -221,7 +221,7 @@ export function prepareFolderListIds(
usersById: Record<number, ApiUser>, usersById: Record<number, ApiUser>,
folder: ApiChatFolder, folder: ApiChatFolder,
notifySettings: NotifySettings, notifySettings: NotifySettings,
notifyExceptions: Record<number, NotifyException>, notifyExceptions?: Record<number, NotifyException>,
chatIdsCache?: number[], chatIdsCache?: number[],
) { ) {
const excludedChatIds = folder.excludedChatIds ? new Set(folder.excludedChatIds) : undefined; const excludedChatIds = folder.excludedChatIds ? new Set(folder.excludedChatIds) : undefined;
@ -249,7 +249,7 @@ function filterChatFolder(
folder: ApiChatFolder, folder: ApiChatFolder,
usersById: Record<number, ApiUser>, usersById: Record<number, ApiUser>,
notifySettings: NotifySettings, notifySettings: NotifySettings,
notifyExceptions: Record<number, NotifyException>, notifyExceptions?: Record<number, NotifyException>,
excludedChatIds?: Set<number>, excludedChatIds?: Set<number>,
includedChatIds?: Set<number>, includedChatIds?: Set<number>,
pinnedChatIds?: Set<number>, pinnedChatIds?: Set<number>,
@ -363,9 +363,9 @@ export function getFolderUnreadDialogs(
chatsById: Record<number, ApiChat>, chatsById: Record<number, ApiChat>,
usersById: Record<number, ApiUser>, usersById: Record<number, ApiUser>,
folder: ApiChatFolder, folder: ApiChatFolder,
notifySettings: NotifySettings,
notifyExceptions: Record<number, NotifyException>,
chatIdsCache: number[], chatIdsCache: number[],
notifySettings: NotifySettings,
notifyExceptions?: Record<number, NotifyException>,
) { ) {
const [listIds] = prepareFolderListIds(chatsById, usersById, folder, notifySettings, notifyExceptions, chatIdsCache); const [listIds] = prepareFolderListIds(chatsById, usersById, folder, notifySettings, notifyExceptions, chatIdsCache);
@ -391,10 +391,10 @@ export function getFolderDescriptionText(
chatsById: Record<number, ApiChat>, chatsById: Record<number, ApiChat>,
usersById: Record<number, ApiUser>, usersById: Record<number, ApiUser>,
folder: ApiChatFolder, folder: ApiChatFolder,
notifySettings: NotifySettings,
notifyExceptions: Record<number, NotifyException>,
chatIdsCache: number[], chatIdsCache: number[],
lang: LangFn, lang: LangFn,
notifySettings: NotifySettings,
notifyExceptions?: Record<number, NotifyException>,
) { ) {
const { const {
id, title, emoticon, description, pinnedChatIds, id, title, emoticon, description, pinnedChatIds,
@ -410,7 +410,7 @@ export function getFolderDescriptionText(
|| (excludedChatIds && excludedChatIds.length) || (excludedChatIds && excludedChatIds.length)
|| (includedChatIds && includedChatIds.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); return lang('Chats', length);
} }
@ -434,9 +434,9 @@ function getFolderChatsCount(
chatsById: Record<number, ApiChat>, chatsById: Record<number, ApiChat>,
usersById: Record<number, ApiUser>, usersById: Record<number, ApiUser>,
folder: ApiChatFolder, folder: ApiChatFolder,
notifySettings: NotifySettings,
notifyExceptions: Record<number, NotifyException>,
chatIdsCache: number[], chatIdsCache: number[],
notifySettings: NotifySettings,
notifyExceptions?: Record<number, NotifyException>,
) { ) {
const [listIds, pinnedIds] = prepareFolderListIds( const [listIds, pinnedIds] = prepareFolderListIds(
chatsById, usersById, folder, notifySettings, notifyExceptions, chatIdsCache, chatsById, usersById, folder, notifySettings, notifyExceptions, chatIdsCache,