Add CurrentVariablePointer to Chat.svelte and CurrentVariablePointer store in stores.ts

This commit is contained in:
kwaroran
2024-04-10 11:59:14 +09:00
parent 0d4b89ff80
commit 1d368ddc3c
2 changed files with 20 additions and 10 deletions

View File

@@ -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}
</span>
{/if}
</span>

View File

@@ -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)
}
})