refactor name and icon get

This commit is contained in:
kwaroran
2024-07-29 23:36:52 +09:00
parent 47c3fab589
commit 9d5b5da351
13 changed files with 73 additions and 45 deletions

View File

@@ -2,7 +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";
import { getUserIcon, getUserName, sleep } from "./util";
import { getModules } from "./process/modules";
function updateSize(){
@@ -76,8 +76,8 @@ function trySync(){
CurrentCharacter.set(structuredClone(currentCharacter))
CurrentSimpleCharacter.set(createSimpleCharacter(currentCharacter))
CurrentChat.set(structuredClone(currentChat))
CurrentUsername.set(db.username)
CurrentUserIcon.set(db.userIcon)
CurrentUsername.set(getUserName())
CurrentUserIcon.set(getUserIcon())
CurrentShowMemoryLimit.set(db.showMemoryLimit)
} catch (error) {}
}
@@ -132,10 +132,10 @@ async function preInit(){
DataBase.subscribe((data) => {
updateCurrentCharacter()
if(data.username !== get(CurrentUsername)){
CurrentUsername.set(data.username)
if(getUserName() !== get(CurrentUsername)){
CurrentUsername.set(getUserName())
}
if(data.userIcon !== get(CurrentUserIcon)){
if(getUserIcon() !== get(CurrentUserIcon)){
CurrentUserIcon.set(data.userIcon)
}
if(data.showMemoryLimit !== get(CurrentShowMemoryLimit)){
@@ -189,6 +189,14 @@ async function preInit(){
return
}
if(getUserName() !== get(CurrentUsername)){
CurrentUsername.set(getUserName())
}
if(getUserIcon() !== get(CurrentUserIcon)){
CurrentUserIcon.set(getUserIcon())
}
const variablePointer = get(CurrentVariablePointer)
const currentState = structuredClone(chat?.scriptstate)