From 1d368ddc3cf832e505b48fb5e080b284f4bfc9da Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 10 Apr 2024 11:59:14 +0900 Subject: [PATCH] Add CurrentVariablePointer to Chat.svelte and CurrentVariablePointer store in stores.ts --- src/lib/ChatScreens/Chat.svelte | 14 ++++++++------ src/ts/stores.ts | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/lib/ChatScreens/Chat.svelte b/src/lib/ChatScreens/Chat.svelte index 14c0413b..3bc8e8b6 100644 --- a/src/lib/ChatScreens/Chat.svelte +++ b/src/lib/ChatScreens/Chat.svelte @@ -5,7 +5,7 @@ import { alertConfirm, alertError, alertRequestData } from "../../ts/alert"; import { language } from "../../lang"; import { DataBase, type MessageGenerationInfo } from "../../ts/storage/database"; - import { CurrentCharacter, CurrentChat } from "../../ts/stores"; + import { CurrentCharacter, CurrentChat, CurrentVariablePointer } from "../../ts/stores"; import { translateHTML } from "../../ts/translator/translator"; import { risuChatParser } from "src/ts/process/scripts"; import { get } from "svelte/store"; @@ -228,11 +228,13 @@ style:font-size="{0.875 * ($DataBase.zoomsize / 100)}rem" style:line-height="{1.25 * ($DataBase.zoomsize / 100)}rem" > - {#await markParsing(msgDisplay, character, 'normal', idx, translated)} - {@html lastParsed} - {:then md} - {@html md} - {/await} + {#key $CurrentVariablePointer} + {#await markParsing(msgDisplay, character, 'normal', idx, translated)} + {@html lastParsed} + {:then md} + {@html md} + {/await} + {/key} {/if} diff --git a/src/ts/stores.ts b/src/ts/stores.ts index 6439854b..1a149126 100644 --- a/src/ts/stores.ts +++ b/src/ts/stores.ts @@ -38,6 +38,7 @@ export const CurrentUserIcon = writable(db.userIcon) export const CurrentShowMemoryLimit = writable(db.showMemoryLimit) export const ShowVN = writable(false) export const SettingsMenuIndex = writable(-1) +export const CurrentVariablePointer = writable({} as {[key:string]: string|number|boolean}) function createSimpleCharacter(char:character|groupChat){ if((!char) || char.type === 'group'){ @@ -136,12 +137,19 @@ CurrentCharacter.subscribe((char) => { CurrentChat.subscribe((chat) => { let currentChar = get(CurrentCharacter) + if(currentChar){ - if(isEqual(currentChar.chats[currentChar.chatPage], chat)){ - return + if(!isEqual(currentChar.chats[currentChar.chatPage], chat)){ + currentChar.chats[currentChar.chatPage] = cloneDeep(chat) + CurrentCharacter.set(currentChar) } - currentChar.chats[currentChar.chatPage] = cloneDeep(chat) - CurrentCharacter.set(currentChar) + } + + const variablePointer = get(CurrentVariablePointer) + const currentState = chat.scriptstate + + if(!isEqual(variablePointer, currentState)){ + CurrentVariablePointer.set(currentState) } })