Fix migrations

This commit is contained in:
Jip Fr 2023-11-01 13:57:48 +01:00
parent 6ba57d701f
commit 5bb2e8203c
3 changed files with 7 additions and 0 deletions

View file

@ -15,6 +15,7 @@ import "@/setup/index.css";
import { useLanguageStore } from "@/stores/language";
import { initializeChromecast } from "./setup/chromecast";
import "./stores/__old/imports";
import { initializeOldStores } from "./stores/__old/migrations";
// initialize

View file

@ -0,0 +1,4 @@
import "./bookmark/store";
import "./settings/store";
import "./volume/store";
import "./watched/store";

View file

@ -27,6 +27,7 @@ const storeCallbacks: Record<string, ((data: any) => void)[]> = {};
const stores: Record<string, [StoreRet<any>, InternalStoreData]> = {};
export async function initializeOldStores() {
console.log(stores);
// migrate all stores
for (const [store, internal] of Object.values(stores)) {
const versions = internal.versions.sort((a, b) => a.version - b.version);
@ -168,6 +169,7 @@ export function createVersionedStore<T>(): StoreBuilder<T> {
return this;
},
build() {
console.log(_data.key);
assertStore(_data);
const storageObject = buildStorageObject<T>(_data);
stores[_data.key ?? ""] = [storageObject, _data];