Fix trigger updating

This commit is contained in:
kwaroran
2024-09-18 22:51:22 +09:00
parent 32d6c02130
commit 6ad841e931
2 changed files with 36 additions and 20 deletions

View File

@@ -8,7 +8,7 @@
import { CurrentCharacter, CurrentChat, CurrentVariablePointer, HideIconStore, ReloadGUIPointer } from "../../ts/stores"; import { CurrentCharacter, CurrentChat, CurrentVariablePointer, HideIconStore, ReloadGUIPointer } 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, type Unsubscriber } from "svelte/store";
import { isEqual } from "lodash"; import { isEqual } from "lodash";
import { sayTTS } from "src/ts/process/tts"; import { sayTTS } from "src/ts/process/tts";
import { getModelShortName } from "src/ts/model/names"; import { getModelShortName } from "src/ts/model/names";
@@ -16,6 +16,7 @@
import { longpress } from "src/ts/gui/longtouch"; import { longpress } from "src/ts/gui/longtouch";
import { ColorSchemeTypeStore } from "src/ts/gui/colorscheme"; import { ColorSchemeTypeStore } from "src/ts/gui/colorscheme";
import { ConnectionOpenStore } from "src/ts/sync/multiuser"; import { ConnectionOpenStore } from "src/ts/sync/multiuser";
import { onDestroy, onMount } from "svelte";
export let message = '' export let message = ''
export let name = '' export let name = ''
export let largePortrait = false export let largePortrait = false
@@ -72,7 +73,7 @@
$CurrentChat.message = msg $CurrentChat.message = msg
} }
function displaya(message:string, chatPointer?:any){ function displaya(message:string){
msgDisplay = risuChatParser(message, {chara: name, chatID: idx, rmVar: true, visualize: true}) msgDisplay = risuChatParser(message, {chara: name, chatID: idx, rmVar: true, visualize: true})
} }
@@ -107,7 +108,6 @@
if(!$DataBase.legacyTranslation){ if(!$DataBase.legacyTranslation){
const marked = await ParseMarkdown(data, charArg, 'pretranslate', chatID) const marked = await ParseMarkdown(data, charArg, 'pretranslate', chatID)
translating = true translating = true
console.log(marked)
const translated = await postTranslationParse(await translateHTML(marked, false, charArg, chatID)) const translated = await postTranslationParse(await translateHTML(marked, false, charArg, chatID))
translating = false translating = false
lastParsed = translated lastParsed = translated
@@ -141,7 +141,22 @@
} }
} }
$: displaya(message, $CurrentVariablePointer) $: displaya(message)
const unsubscribers:Unsubscriber[] = []
onMount(()=>{
unsubscribers.push(CurrentVariablePointer.subscribe((v) => {
displaya(message)
}))
unsubscribers.push(ReloadGUIPointer.subscribe((v) => {
displaya(message)
}))
})
onDestroy(()=>{
unsubscribers.forEach(u => u())
})
</script> </script>
<div class="flex max-w-full justify-center risu-chat" style={isLastMemory ? `border-top:${$DataBase.memoryLimitThickness}px solid rgba(98, 114, 164, 0.7);` : ''}> <div class="flex max-w-full justify-center risu-chat" style={isLastMemory ? `border-top:${$DataBase.memoryLimitThickness}px solid rgba(98, 114, 164, 0.7);` : ''}>
<div class="text-textcolor mt-1 ml-4 mr-4 mb-1 p-2 bg-transparent flex-grow border-t-gray-900 border-opacity-30 border-transparent flexium items-start max-w-full" > <div class="text-textcolor mt-1 ml-4 mr-4 mb-1 p-2 bg-transparent flex-grow border-t-gray-900 border-opacity-30 border-transparent flexium items-start max-w-full" >

View File

@@ -3,7 +3,7 @@ import { DataBase, type Chat, type character } from "../storage/database";
import { tokenize } from "../tokenizer"; import { tokenize } from "../tokenizer";
import { getModuleTriggers } from "./modules"; import { getModuleTriggers } from "./modules";
import { get } from "svelte/store"; import { get } from "svelte/store";
import { CurrentCharacter, CurrentChat, selectedCharID } from "../stores"; import { CurrentCharacter, CurrentChat, ReloadGUIPointer, selectedCharID } from "../stores";
import { processMultiCommand } from "./command"; import { processMultiCommand } from "./command";
import { parseKeyValue } from "../util"; import { parseKeyValue } from "../util";
import { alertError, alertInput, alertNormal, alertSelect } from "../alert"; import { alertError, alertInput, alertNormal, alertSelect } from "../alert";
@@ -531,6 +531,7 @@ export async function runTrigger(char:character,mode:triggerMode, arg:{
if(varChanged){ if(varChanged){
const currentChat = get(CurrentChat) const currentChat = get(CurrentChat)
currentChat.scriptstate = chat.scriptstate currentChat.scriptstate = chat.scriptstate
ReloadGUIPointer.set(get(ReloadGUIPointer) + 1)
} }
return {additonalSysPrompt, chat, tokens:caculatedTokens, stopSending, sendAIprompt} return {additonalSysPrompt, chat, tokens:caculatedTokens, stopSending, sendAIprompt}