Browse Source

Fix migrations

pull/497/head
Jip Fr 2 years ago
parent
commit
5bb2e8203c
  1. 1
      src/index.tsx
  2. 4
      src/stores/__old/imports.ts
  3. 2
      src/stores/__old/migrations.ts

1
src/index.tsx

@ -15,6 +15,7 @@ import "@/setup/index.css"; @@ -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

4
src/stores/__old/imports.ts

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

2
src/stores/__old/migrations.ts

@ -27,6 +27,7 @@ const storeCallbacks: Record<string, ((data: any) => void)[]> = {}; @@ -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> { @@ -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];

Loading…
Cancel
Save