chore: Update svelte/store imports and initialize writable values
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
import "core-js/actual"
|
import "core-js/actual"
|
||||||
|
import "./ts/storage/database"
|
||||||
import App from "./App.svelte";
|
import App from "./App.svelte";
|
||||||
import { loadData } from "./ts/storage/globalApi";
|
import { loadData } from "./ts/storage/globalApi";
|
||||||
import { initHotkey } from "./ts/hotkey";
|
import { initHotkey } from "./ts/hotkey";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { get, writable } from "svelte/store";
|
import { get, writable, type Writable } from "svelte/store";
|
||||||
import { DataBase, type character, type groupChat } from "./storage/database";
|
import { DataBase, type Chat, type character, type groupChat } from "./storage/database";
|
||||||
import { isEqual } from "lodash";
|
import { isEqual } from "lodash";
|
||||||
import type { simpleCharacterArgument } from "./parser";
|
import type { simpleCharacterArgument } from "./parser";
|
||||||
|
|
||||||
@@ -30,12 +30,20 @@ let db = get(DataBase)
|
|||||||
let currentChar = get(selectedCharID)
|
let currentChar = get(selectedCharID)
|
||||||
let currentCharacter = db.characters ? (db.characters[currentChar]) : null
|
let currentCharacter = db.characters ? (db.characters[currentChar]) : null
|
||||||
let currentChat = currentCharacter ? (currentCharacter.chats[currentCharacter.chatPage]) : null
|
let currentChat = currentCharacter ? (currentCharacter.chats[currentCharacter.chatPage]) : null
|
||||||
export const CurrentCharacter = writable(structuredClone(currentCharacter))
|
export const CurrentCharacter = writable(null) as Writable<character | groupChat>
|
||||||
export const CurrentSimpleCharacter = writable(createSimpleCharacter(currentCharacter))
|
export const CurrentSimpleCharacter = writable(null) as Writable<simpleCharacterArgument>
|
||||||
export const CurrentChat = writable(structuredClone(currentChat))
|
export const CurrentChat = writable(null) as Writable<Chat>
|
||||||
export const CurrentUsername = writable(db.username)
|
export const CurrentUsername = writable('') as Writable<string>
|
||||||
export const CurrentUserIcon = writable(db.userIcon)
|
export const CurrentUserIcon = writable('') as Writable<string>
|
||||||
export const CurrentShowMemoryLimit = writable(db.showMemoryLimit)
|
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 ShowVN = writable(false)
|
||||||
export const SettingsMenuIndex = writable(-1)
|
export const SettingsMenuIndex = writable(-1)
|
||||||
export const CurrentVariablePointer = writable({} as {[key:string]: string|number|boolean})
|
export const CurrentVariablePointer = writable({} as {[key:string]: string|number|boolean})
|
||||||
|
|||||||
Reference in New Issue
Block a user