chore: Update svelte/store imports and initialize writable values

This commit is contained in:
kwaroran
2024-06-24 01:09:35 +09:00
parent fa322f741a
commit ffe4b471e9
2 changed files with 17 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
import "./styles.css";
import "core-js/actual"
import "./ts/storage/database"
import App from "./App.svelte";
import { loadData } from "./ts/storage/globalApi";
import { initHotkey } from "./ts/hotkey";

View File

@@ -1,5 +1,5 @@
import { get, writable } from "svelte/store";
import { DataBase, type character, type groupChat } from "./storage/database";
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";
@@ -30,12 +30,20 @@ let db = get(DataBase)
let currentChar = get(selectedCharID)
let currentCharacter = db.characters ? (db.characters[currentChar]) : null
let currentChat = currentCharacter ? (currentCharacter.chats[currentCharacter.chatPage]) : null
export const CurrentCharacter = writable(structuredClone(currentCharacter))
export const CurrentSimpleCharacter = writable(createSimpleCharacter(currentCharacter))
export const CurrentChat = writable(structuredClone(currentChat))
export const CurrentUsername = writable(db.username)
export const CurrentUserIcon = writable(db.userIcon)
export const CurrentShowMemoryLimit = writable(db.showMemoryLimit)
export const CurrentCharacter = writable(null) as Writable<character | groupChat>
export const CurrentSimpleCharacter = writable(null) as Writable<simpleCharacterArgument>
export const CurrentChat = writable(null) as Writable<Chat>
export const CurrentUsername = writable('') as Writable<string>
export const CurrentUserIcon = writable('') as Writable<string>
export const CurrentShowMemoryLimit = writable(false) as Writable<boolean>
try {
CurrentCharacter.set(structuredClone(currentCharacter))
CurrentSimpleCharacter.set(createSimpleCharacter(currentCharacter))
CurrentChat.set(structuredClone(currentChat))
CurrentUsername.set(db.username)
CurrentUserIcon.set(db.userIcon)
CurrentShowMemoryLimit.set(db.showMemoryLimit)
} catch (error) {}
export const ShowVN = writable(false)
export const SettingsMenuIndex = writable(-1)
export const CurrentVariablePointer = writable({} as {[key:string]: string|number|boolean})