Fix background embedding

This commit is contained in:
kwaroran
2024-11-03 22:26:20 +09:00
parent 4f41461f86
commit b51bbad838
3 changed files with 17 additions and 13 deletions

View File

@@ -2,16 +2,16 @@
import { ParseMarkdown, risuChatParser } from "src/ts/parser.svelte";
import { type character, type groupChat } from "src/ts/storage/database.svelte";
import { DBState } from 'src/ts/stores.svelte';
import { moduleBackgroundEmbedding, ReloadGUIPointer, selectedCharID } from "src/ts/stores.svelte";
import { moduleBackgroundEmbedding, ReloadGUIPointer, selIdState } from "src/ts/stores.svelte";
let backgroundHTML = $derived(DBState.db?.characters?.[$selectedCharID]?.backgroundHTML)
let backgroundHTML = $derived(DBState.db?.characters?.[selIdState.selId]?.backgroundHTML)
let currentChar:character|groupChat = $state()
</script>
{#if backgroundHTML || $moduleBackgroundEmbedding}
{#if $selectedCharID > -1}
{#if selIdState.selId > -1}
{#key $ReloadGUIPointer}
<div class="absolute top-0 left-0 w-full h-full">
{#await ParseMarkdown(risuChatParser((backgroundHTML || '') + ($moduleBackgroundEmbedding || ''), {chara:currentChar}), currentChar, 'back') then md}

View File

@@ -8,7 +8,7 @@ import { convertExternalLorebook } from "./lorebook.svelte"
import { decodeRPack, encodeRPack } from "../rpack/rpack_bg"
import { convertImage } from "../parser.svelte"
import { Capacitor } from "@capacitor/core"
import { HideIconStore, moduleBackgroundEmbedding } from "../stores.svelte"
import { DBState, HideIconStore, moduleBackgroundEmbedding } from "../stores.svelte"
export interface RisuModule{
name: string
@@ -397,7 +397,6 @@ export async function applyModule() {
let lastGlobalEnabledModules: string[] = []
let lastChatEnabledModules: string[] = []
let characterHideIcon = false
export function moduleUpdate(){
if(!Array.isArray(lastGlobalEnabledModules)){
@@ -425,7 +424,10 @@ export function moduleUpdate(){
})
if(backgroundEmbedding){
console.log('Background Embedding:', backgroundEmbedding)
moduleBackgroundEmbedding.set(backgroundEmbedding)
}
HideIconStore.set(characterHideIcon || moduleHideIcon)
console.log('Module Hide Icon:', moduleHideIcon)
console.log(Date.now())
HideIconStore.set(getCurrentCharacter()?.hideChatIcon || moduleHideIcon)
}

View File

@@ -49,6 +49,10 @@ export const alertStore = writable({
type: 'none',
msg: 'n',
} as alertData)
export const selIdState = $state({
selId: -1
})
CustomCSSStore.subscribe((css) => {
console.log(css)
@@ -91,18 +95,16 @@ export const DBState = $state({
export const disableHighlight = writable(true)
let selIdState = $state(0)
selectedCharID.subscribe((v) => {
selIdState = v
})
$effect.root(() => {
selectedCharID.subscribe((v) => {
selIdState.selId = v
})
$effect(() => {
$state.snapshot(DBState.db.modules)
DBState?.db?.enabledModules
DBState?.db?.enabledModules?.length
DBState?.db?.characters?.[selIdState]?.chats?.[DBState?.db?.characters?.[selIdState]?.chatPage]?.modules?.length
DBState?.db?.characters?.[selIdState.selId]?.chats?.[DBState?.db?.characters?.[selIdState.selId]?.chatPage]?.modules?.length
DBState?.db?.characters?.[selIdState.selId]?.hideChatIcon
DBState?.db?.moduleIntergration
ReloadGUIPointer.set(get(ReloadGUIPointer) + 1)
moduleUpdate()