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>;
chatFoldersById: Record<number, ApiChatFolder>;
notifySettings: NotifySettings;
notifyExceptions: Record<number, NotifyException>;
notifyExceptions?: Record<number, NotifyException>;
orderedFolderIds?: number[];
lastSyncTime?: number;
};
@ -74,7 +74,7 @@ const ChatFolders: FC<StateProps & DispatchProps> = ({
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,

View File

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

View File

@ -32,7 +32,7 @@ type StateProps = {
foldersById: Record<number, ApiChatFolder>;
recommendedChatFolders?: ApiChatFolder[];
notifySettings: NotifySettings;
notifyExceptions: Record<number, NotifyException>;
notifyExceptions?: Record<number, NotifyException>;
};
type DispatchProps = Pick<GlobalActions, 'loadRecommendedChatFolders' | 'addChatFolder' | 'showError'>;
@ -103,7 +103,7 @@ const SettingsFoldersMain: FC<OwnProps & StateProps & DispatchProps> = ({
id: folder.id,
title: folder.title,
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;
loadedWallpapers?: ApiWallpaper[];
privacy: Partial<Record<ApiPrivacyKey, ApiPrivacySettings>>;
notifyExceptions: Record<number, NotifyException>;
notifyExceptions?: Record<number, NotifyException>;
};
twoFaSettings: {

View File

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