Add CurrentVariablePointer to Chat.svelte and CurrentVariablePointer store in stores.ts
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
import { alertConfirm, alertError, alertRequestData } from "../../ts/alert";
|
import { alertConfirm, alertError, alertRequestData } from "../../ts/alert";
|
||||||
import { language } from "../../lang";
|
import { language } from "../../lang";
|
||||||
import { DataBase, type MessageGenerationInfo } from "../../ts/storage/database";
|
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 { translateHTML } from "../../ts/translator/translator";
|
||||||
import { risuChatParser } from "src/ts/process/scripts";
|
import { risuChatParser } from "src/ts/process/scripts";
|
||||||
import { get } from "svelte/store";
|
import { get } from "svelte/store";
|
||||||
@@ -228,11 +228,13 @@
|
|||||||
style:font-size="{0.875 * ($DataBase.zoomsize / 100)}rem"
|
style:font-size="{0.875 * ($DataBase.zoomsize / 100)}rem"
|
||||||
style:line-height="{1.25 * ($DataBase.zoomsize / 100)}rem"
|
style:line-height="{1.25 * ($DataBase.zoomsize / 100)}rem"
|
||||||
>
|
>
|
||||||
{#await markParsing(msgDisplay, character, 'normal', idx, translated)}
|
{#key $CurrentVariablePointer}
|
||||||
{@html lastParsed}
|
{#await markParsing(msgDisplay, character, 'normal', idx, translated)}
|
||||||
{:then md}
|
{@html lastParsed}
|
||||||
{@html md}
|
{:then md}
|
||||||
{/await}
|
{@html md}
|
||||||
|
{/await}
|
||||||
|
{/key}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export const CurrentUserIcon = writable(db.userIcon)
|
|||||||
export const CurrentShowMemoryLimit = writable(db.showMemoryLimit)
|
export const CurrentShowMemoryLimit = writable(db.showMemoryLimit)
|
||||||
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})
|
||||||
|
|
||||||
function createSimpleCharacter(char:character|groupChat){
|
function createSimpleCharacter(char:character|groupChat){
|
||||||
if((!char) || char.type === 'group'){
|
if((!char) || char.type === 'group'){
|
||||||
@@ -136,12 +137,19 @@ CurrentCharacter.subscribe((char) => {
|
|||||||
|
|
||||||
CurrentChat.subscribe((chat) => {
|
CurrentChat.subscribe((chat) => {
|
||||||
let currentChar = get(CurrentCharacter)
|
let currentChar = get(CurrentCharacter)
|
||||||
|
|
||||||
if(currentChar){
|
if(currentChar){
|
||||||
if(isEqual(currentChar.chats[currentChar.chatPage], chat)){
|
if(!isEqual(currentChar.chats[currentChar.chatPage], chat)){
|
||||||
return
|
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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user