fix: add migration to rename dpi to dpr in custom devices

This commit is contained in:
wp043 2024-08-07 15:19:08 +08:00
parent a5bb9408d9
commit 1e41e38768

View file

@ -86,4 +86,27 @@ export const migrations = {
},
]);
},
'1.13.0': (store: Store) => {
// Migrate dpi to dpr in custom devices
try {
const previousCustomDevices: any[] = store.get(
'deviceManager.customDevices'
) as any[];
const newCustomDevices: Device[] = previousCustomDevices.map((device) => {
const newDevice = {
...device,
dpr: device.dpi !== undefined ? device.dpi : device.dpr,
};
delete newDevice.dpi;
return newDevice as Device;
});
store.set('deviceManager.customDevices', newCustomDevices);
console.log(
'Migration for 1.13.0 successful',
store.get('deviceManager.customDevices')
);
} catch (e) {
console.log('Migration for 1.13.0 failed', e);
}
},
};