Skip to content

Commit

Permalink
fix(suite): device state migration
Browse files Browse the repository at this point in the history
  • Loading branch information
martykan authored and mroz22 committed Oct 30, 2024
1 parent 9394468 commit bb11180
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/suite/src/storage/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1107,11 +1107,16 @@ export const migrate: OnUpgradeFunc<SuiteDBSchema> = async (
if (oldVersion < 48) {
// Migrate device state to new object format
await updateAll(transaction, 'devices', device => {
if (
typeof device.state === 'string' &&
typeof (device as any)?._state?.staticSessionId === 'string'
) {
device.state = (device as any)._state;
if (typeof device.state === 'string') {
if (typeof (device as any)?._state?.staticSessionId === 'string') {
// Has _state property, migrate to that
device.state = (device as any)._state;
} else {
// No _state property, create new object
device.state = {
staticSessionId: device.state,
};
}
}

return device;
Expand Down

0 comments on commit bb11180

Please sign in to comment.