Migrate all DataBase to DBState
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { get } from "svelte/store";
|
||||
import { exportCharacterCard } from "./characterCards";
|
||||
import { VirtualWriter, isTauri, openURL } from "./storage/globalApi";
|
||||
import { DataBase, getCurrentCharacter, type character } from "./storage/database.svelte";
|
||||
import { getCurrentCharacter, getDatabase, type character } from "./storage/database.svelte";
|
||||
import { alertStore } from "./alert";
|
||||
|
||||
let pong = false;
|
||||
@@ -15,7 +15,7 @@ window.addEventListener("message", (event) => {
|
||||
});
|
||||
|
||||
export async function shareRealmCardData():Promise<{ name: ArrayBuffer; data: ArrayBuffer; }> {
|
||||
const char = structuredClone(getCurrentCharacter()) as character
|
||||
const char = structuredClone(getCurrentCharacter({snapshot:true})) as character
|
||||
const trimedName = char.name.replace(/[^a-zA-Z0-9]/g, '') || 'character';
|
||||
const writer = new VirtualWriter()
|
||||
const namebuf = new TextEncoder().encode(trimedName + '.png')
|
||||
@@ -31,8 +31,8 @@ export async function shareRealmCardData():Promise<{ name: ArrayBuffer; data: Ar
|
||||
}
|
||||
|
||||
export async function openRealm(name:string,data:ArrayBuffer) {
|
||||
const tk = get(DataBase)?.account?.token;
|
||||
const id = get(DataBase)?.account?.id
|
||||
const tk = getDatabase()?.account?.token;
|
||||
const id = getDatabase()?.account?.id
|
||||
const trimedName = name.replace(/[^a-zA-Z0-9]/g, '') || 'character';
|
||||
const filedata = encodeURIComponent(Buffer.from(data).toString('base64')) + `&${trimedName}.png`;
|
||||
const url = `https://realm.risuai.net/upload?token=${tk}&token_id=${id}#filedata=${filedata}`
|
||||
|
||||
Reference in New Issue
Block a user