2023-02-12 00:41:55 +01:00
|
|
|
import { createVersionedStore } from "@/utils/storage";
|
2023-04-24 18:41:54 +03:00
|
|
|
|
|
|
|
import { OldData, migrateV2Videos } from "./migrations/v2";
|
2023-06-22 10:47:14 +02:00
|
|
|
import { migrateV3Videos } from "./migrations/v3";
|
2023-02-12 00:41:55 +01:00
|
|
|
import { WatchedStoreData } from "./types";
|
2023-02-11 01:05:27 +01:00
|
|
|
|
2023-02-12 00:41:55 +01:00
|
|
|
export const VideoProgressStore = createVersionedStore<WatchedStoreData>()
|
2023-02-11 01:05:27 +01:00
|
|
|
.setKey("video-progress")
|
2022-03-06 18:31:05 +01:00
|
|
|
.addVersion({
|
|
|
|
version: 0,
|
2023-01-12 22:04:28 +01:00
|
|
|
migrate() {
|
2023-01-12 22:36:28 +01:00
|
|
|
return {
|
2023-02-12 00:41:55 +01:00
|
|
|
items: [], // dont migrate from version 0 to version 1, unmigratable
|
2023-01-12 22:36:28 +01:00
|
|
|
};
|
2022-03-06 18:31:05 +01:00
|
|
|
},
|
2023-01-10 22:43:27 +01:00
|
|
|
})
|
|
|
|
.addVersion({
|
2023-02-12 00:41:55 +01:00
|
|
|
version: 1,
|
|
|
|
async migrate(old: OldData) {
|
2023-02-12 14:03:50 +01:00
|
|
|
return migrateV2Videos(old);
|
2023-01-10 22:43:27 +01:00
|
|
|
},
|
2023-02-12 00:41:55 +01:00
|
|
|
})
|
|
|
|
.addVersion({
|
|
|
|
version: 2,
|
2023-06-22 22:37:16 +02:00
|
|
|
migrate(old: WatchedStoreData) {
|
2023-06-22 10:47:14 +02:00
|
|
|
return migrateV3Videos(old);
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.addVersion({
|
|
|
|
version: 3,
|
2022-03-06 18:31:05 +01:00
|
|
|
create() {
|
|
|
|
return {
|
|
|
|
items: [],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.build();
|