tooot/src/utils/migrations/instances/migration.ts

94 lines
2.3 KiB
TypeScript
Raw Normal View History

2021-03-17 15:30:28 +01:00
import { InstanceV3 } from './v3'
import { InstanceV4 } from './v4'
2021-11-15 22:34:43 +01:00
import { InstanceV5 } from './v5'
2022-01-16 23:26:05 +01:00
import { InstanceV6 } from './v6'
2022-02-12 14:51:01 +01:00
import { InstanceV7 } from './v7'
2022-02-13 22:14:16 +01:00
import { InstanceV8 } from './v8'
2021-03-17 15:30:28 +01:00
const instancesMigration = {
2022-02-12 14:51:01 +01:00
4: (state: InstanceV3): InstanceV4 => {
2021-03-17 15:30:28 +01:00
return {
instances: state.local.instances.map((instance, index) => {
2022-02-12 14:51:01 +01:00
const { notification, ...rest } = instance
2021-03-17 15:30:28 +01:00
return {
2022-02-12 14:51:01 +01:00
...rest,
2021-03-17 15:30:28 +01:00
active: state.local.activeIndex === index,
push: {
global: { loading: false, value: false },
decode: { loading: false, value: false },
alerts: {
follow: { loading: false, value: true },
favourite: { loading: false, value: true },
reblog: { loading: false, value: true },
mention: { loading: false, value: true },
poll: { loading: false, value: true }
},
keys: undefined
}
}
})
}
},
2022-02-12 14:51:01 +01:00
5: (state: InstanceV4): InstanceV5 => {
2021-03-17 15:30:28 +01:00
// @ts-ignore
if (state.instances.length && !state.instances[0].notifications_filter) {
return {
2022-02-12 14:51:01 +01:00
// @ts-ignore
2021-03-17 15:30:28 +01:00
instances: state.instances.map(instance => {
2022-02-12 14:51:01 +01:00
return {
...instance,
notifications_filter: {
follow: true,
favourite: true,
reblog: true,
mention: true,
poll: true,
follow_request: true
}
2021-03-17 15:30:28 +01:00
}
})
}
} else {
2022-02-12 14:51:01 +01:00
// @ts-ignore
2021-03-17 15:30:28 +01:00
return state
}
2021-11-15 22:34:43 +01:00
},
2022-02-12 14:51:01 +01:00
6: (state: InstanceV5): InstanceV6 => {
2021-11-27 18:49:14 +01:00
return {
2022-02-12 14:51:01 +01:00
// @ts-ignore
2021-11-27 18:49:14 +01:00
instances: state.instances.map(instance => {
2022-02-12 14:51:01 +01:00
return {
...instance,
configuration: undefined
}
2021-11-27 18:49:14 +01:00
})
}
2022-01-16 23:26:05 +01:00
},
2022-02-12 14:51:01 +01:00
7: (state: InstanceV6): InstanceV7 => {
2022-01-16 23:26:05 +01:00
return {
instances: state.instances.map(instance => {
return {
...instance,
timelinesLookback: {},
mePage: {
lists: { shown: false },
announcements: { shown: false, unread: 0 }
}
}
})
}
2022-02-13 22:14:16 +01:00
},
8: (state: InstanceV7): InstanceV8 => {
return {
instances: state.instances.map(instance => {
return {
...instance,
frequentEmojis: []
}
})
}
2021-03-17 15:30:28 +01:00
}
}
export default instancesMigration