Migrate deprecated auto download settings
This commit is contained in:
parent
55c9f42c48
commit
7955e20a78
@ -82,10 +82,10 @@ export type State = {
|
||||
sendShortcut: 'enter' | 'ctrlEnter',
|
||||
animationsEnabled: boolean,
|
||||
autoDownload: {
|
||||
contacts: boolean,
|
||||
private: boolean,
|
||||
groups: boolean,
|
||||
channels: boolean,
|
||||
contacts?: boolean, // ! DEPRECATED
|
||||
private?: boolean, // ! DEPRECATED
|
||||
groups?: boolean, // ! DEPRECATED
|
||||
channels?: boolean, // ! DEPRECATED
|
||||
photo: AutoDownloadPeerTypeSettings,
|
||||
video: AutoDownloadPeerTypeSettings,
|
||||
file: AutoDownloadPeerTypeSettings
|
||||
@ -140,10 +140,6 @@ export const STATE_INIT: State = {
|
||||
sendShortcut: 'enter',
|
||||
animationsEnabled: true,
|
||||
autoDownload: {
|
||||
contacts: true,
|
||||
private: true,
|
||||
groups: true,
|
||||
channels: true,
|
||||
photo: {
|
||||
contacts: true,
|
||||
private: true,
|
||||
@ -463,6 +459,36 @@ export class AppStateManager extends EventListenerBase<{
|
||||
}
|
||||
}
|
||||
|
||||
// * migrate auto download settings
|
||||
const autoDownloadSettings = state.settings.autoDownload;
|
||||
if(autoDownloadSettings?.private !== undefined) {
|
||||
const oldTypes = [
|
||||
'contacts' as const,
|
||||
'private' as const,
|
||||
'groups' as const,
|
||||
'channels' as const
|
||||
];
|
||||
|
||||
const mediaTypes = [
|
||||
'photo' as const,
|
||||
'video' as const,
|
||||
'file' as const
|
||||
];
|
||||
|
||||
mediaTypes.forEach(mediaType => {
|
||||
const peerTypeSettings: AutoDownloadPeerTypeSettings = autoDownloadSettings[mediaType] = {} as any;
|
||||
oldTypes.forEach(peerType => {
|
||||
peerTypeSettings[peerType] = autoDownloadSettings[peerType];
|
||||
});
|
||||
});
|
||||
|
||||
oldTypes.forEach(peerType => {
|
||||
delete autoDownloadSettings[peerType];
|
||||
});
|
||||
|
||||
this.pushToState('settings', state.settings);
|
||||
}
|
||||
|
||||
validateInitObject(STATE_INIT, state, (missingKey) => {
|
||||
// @ts-ignore
|
||||
this.pushToState(missingKey, state[missingKey]);
|
||||
|
@ -63,7 +63,7 @@ export interface RefreshReferenceTaskResponse extends WorkerTaskVoidTemplate {
|
||||
originalPayload: ReferenceBytes
|
||||
};
|
||||
|
||||
const MAX_FILE_SAVE_SIZE = 20e6;
|
||||
const MAX_FILE_SAVE_SIZE = 20 * 1024 * 1024;
|
||||
|
||||
export class ApiFileManager {
|
||||
private cacheStorage = new CacheStorageController('cachedFiles');
|
||||
|
Loading…
Reference in New Issue
Block a user