refactor: Optimize current character initialization in stores.ts

This commit is contained in:
kwaroran
2024-06-24 01:38:24 +09:00
parent 5f59349b84
commit 6e9940df2d

View File

@@ -2,6 +2,7 @@ import { get, writable, type Writable } from "svelte/store";
import { DataBase, type Chat, type character, type groupChat } from "./storage/database";
import { isEqual } from "lodash";
import type { simpleCharacterArgument } from "./parser";
import { sleep } from "./util";
function updateSize(){
SizeStore.set({
@@ -70,6 +71,8 @@ function createSimpleCharacter(char:character|groupChat){
}
async function preInit(){
await sleep(1)
function updateCurrentCharacter(){
const db = get(DataBase)
@@ -163,7 +166,9 @@ CurrentChat.subscribe((chat) => {
CurrentVariablePointer.set(currentState)
}
})
}
updateSize()
window.addEventListener("resize", updateSize);
preInit()