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