refactor: Optimize current character initialization in stores.ts
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user