Migrate all DataBase to DBState

This commit is contained in:
kwaroran
2024-10-24 01:59:57 +09:00
parent 4e9190f1b5
commit b3fddb814e
65 changed files with 331 additions and 434 deletions

View File

@@ -1,9 +1,9 @@
import { get, writable } from "svelte/store"
import { DataBase } from "./database.svelte"
import { writable } from "svelte/store"
import { getDatabase } from "./database.svelte"
import { hubURL } from "../characterCards"
import localforage from "localforage"
import { alertError, alertLogin, alertStore, alertWait } from "../alert"
import { forageStorage, getUnpargeables, replaceDbResources } from "./globalApi"
import { alertLogin, alertStore, alertWait } from "../alert"
import { forageStorage, getUnpargeables } from "./globalApi"
import { encodeRisuSave } from "./risuSave"
import { v4 } from "uuid"
import { language } from "src/lang"
@@ -99,7 +99,7 @@ export class AccountStorage{
return Buffer.from(ab)
}
async keys():Promise<string[]>{
let db = get(DataBase)
let db = getDatabase()
return getUnpargeables(db, 'pure')
}
async removeItem(key:string){
@@ -107,7 +107,7 @@ export class AccountStorage{
}
private checkAuth(){
const db = get(DataBase)
const db = getDatabase()
this.auth = db?.account?.token
if(!this.auth){
db.account = JSON.parse(localStorage.getItem("fallbackRisuToken"))
@@ -122,7 +122,7 @@ export class AccountStorage{
export async function unMigrationAccount() {
const keys = await forageStorage.keys()
let db = get(DataBase)
let db = getDatabase()
let i = 0;
const MigrationStorage = localforage.createInstance({name: "risuai"})