From 9afd4e888a54b43f6bfe7eb44ce025400bd5bd05 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sat, 4 Mar 2023 03:16:30 +0100 Subject: [PATCH] Archive: Fix invalid migration; Drop stale migrations (#2750) --- src/global/cache.ts | 47 ++++----------------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/src/global/cache.ts b/src/global/cache.ts index 0cadf0ee3..1c8d7f502 100644 --- a/src/global/cache.ts +++ b/src/global/cache.ts @@ -140,33 +140,6 @@ export function migrateCache(cached: GlobalState, initialState: GlobalState) { } function unsafeMigrateCache(cached: GlobalState, initialState: GlobalState) { - // Migrate from legacy setting names - if ('shouldAutoDownloadMediaFromContacts' in cached.settings.byKey) { - const { - shouldAutoDownloadMediaFromContacts, - shouldAutoDownloadMediaInPrivateChats, - shouldAutoDownloadMediaInGroups, - shouldAutoDownloadMediaInChannels, - shouldAutoPlayVideos, - shouldAutoPlayGifs, - ...rest - } = cached.settings.byKey; - - cached.settings.byKey = { - ...rest, - canAutoLoadPhotoFromContacts: shouldAutoDownloadMediaFromContacts, - canAutoLoadVideoFromContacts: shouldAutoDownloadMediaFromContacts, - canAutoLoadPhotoInPrivateChats: shouldAutoDownloadMediaInPrivateChats, - canAutoLoadVideoInPrivateChats: shouldAutoDownloadMediaInPrivateChats, - canAutoLoadPhotoInGroups: shouldAutoDownloadMediaInGroups, - canAutoLoadVideoInGroups: shouldAutoDownloadMediaInGroups, - canAutoLoadPhotoInChannels: shouldAutoDownloadMediaInChannels, - canAutoLoadVideoInChannels: shouldAutoDownloadMediaInChannels, - canAutoPlayVideos: shouldAutoPlayVideos, - canAutoPlayGifs: shouldAutoPlayGifs, - }; - } - // Pre-fill settings with defaults cached.settings.byKey = { ...initialState.settings.byKey, @@ -183,26 +156,10 @@ function unsafeMigrateCache(cached: GlobalState, initialState: GlobalState) { ...cached.chatFolders, }; - if (!cached.stickers.greeting) { - cached.stickers.greeting = initialState.stickers.greeting; - } - if (!cached.stickers.premium) { cached.stickers.premium = initialState.stickers.premium; } - if (!cached.serviceNotifications) { - cached.serviceNotifications = []; - } - - if (!cached.users.statusesById) { - cached.users.statusesById = {}; - } - - if (!cached.messages.sponsoredByChatId) { - cached.messages.sponsoredByChatId = {}; - } - if (!cached.attachMenu) { cached.attachMenu = { bots: {}, @@ -328,6 +285,10 @@ function unsafeMigrateCache(cached: GlobalState, initialState: GlobalState) { cached.availableReactions = cached.availableReactions .map((r) => ({ ...r, reaction: { emoticon: r.reaction as unknown as string } })); } + + if (!cached.archiveSettings) { + cached.archiveSettings = initialState.archiveSettings; + } } function updateCache() {