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 { useLanguageStore } from "@/stores/language";
import { initializeChromecast } from "./setup/chromecast"; import { initializeChromecast } from "./setup/chromecast";
import "./stores/__old/imports";
import { initializeOldStores } from "./stores/__old/migrations"; import { initializeOldStores } from "./stores/__old/migrations";
// initialize // 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]> = {}; const stores: Record<string, [StoreRet<any>, InternalStoreData]> = {};
export async function initializeOldStores() { export async function initializeOldStores() {
console.log(stores);
// migrate all stores // migrate all stores
for (const [store, internal] of Object.values(stores)) { for (const [store, internal] of Object.values(stores)) {
const versions = internal.versions.sort((a, b) => a.version - b.version); const versions = internal.versions.sort((a, b) => a.version - b.version);
@ -168,6 +169,7 @@ export function createVersionedStore<T>(): StoreBuilder<T> {
return this; return this;
}, },
build() { build() {
console.log(_data.key);
assertStore(_data); assertStore(_data);
const storageObject = buildStorageObject<T>(_data); const storageObject = buildStorageObject<T>(_data);
stores[_data.key ?? ""] = [storageObject, _data]; stores[_data.key ?? ""] = [storageObject, _data];