Fix lazy portal

This commit is contained in:
Kwaroran
2025-05-17 02:46:14 +09:00
parent 665253e404
commit 52d2c626d0
5 changed files with 22 additions and 26 deletions

View File

@@ -661,13 +661,15 @@
{#each blocks as block, i} {#each blocks as block, i}
<div <div
class="w-full max-w-full" id={'x-chat-' + (blocks.length - i - 1)} class="w-full max-w-full lazy-portal" id={'x-lazy-portal-' + (blocks.length - i - 1)}
bind:this={blockEle[blocks.length - i - 1]} bind:this={blockEle[blocks.length - i - 1]}
> >
</div> </div>
{/each} {/each}
{#if DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message?.[0]?.data?.startsWith(coldStorageHeader) } {#if DBState.db.characters[$selectedCharID].chats[DBState.db.characters[$selectedCharID].chatPage].message?.[0]?.data?.startsWith(coldStorageHeader) }
{#await preLoadChat($selectedCharID, DBState.db.characters[$selectedCharID].chatPage)} {#await preLoadChat($selectedCharID, DBState.db.characters[$selectedCharID].chatPage)}
<div class="w-full flex justify-center text-textcolor2 italic mb-12"> <div class="w-full flex justify-center text-textcolor2 italic mb-12">
@@ -728,6 +730,15 @@
<LazyPortal root={root} target={blockEle[0]}> <LazyPortal root={root} target={blockEle[0]}>
{#if DBState.db.characters[$selectedCharID].type !== 'group' } {#if DBState.db.characters[$selectedCharID].type !== 'group' }
{#if !DBState.db.characters[$selectedCharID].removedQuotes && DBState.db.characters[$selectedCharID].creatorNotes.length >= 2}
<CreatorQuote quote={DBState.db.characters[$selectedCharID].creatorNotes} onRemove={() => {
const cha = DBState.db.characters[$selectedCharID]
if(cha.type !== 'group'){
cha.removedQuotes = true
}
DBState.db.characters[$selectedCharID] = cha
}} />
{/if}
<Chat <Chat
character={createSimpleCharacter(DBState.db.characters[$selectedCharID])} character={createSimpleCharacter(DBState.db.characters[$selectedCharID])}
name={DBState.db.characters[$selectedCharID].name} name={DBState.db.characters[$selectedCharID].name}
@@ -767,15 +778,6 @@
isLastMemory={false} isLastMemory={false}
/> />
{#if !DBState.db.characters[$selectedCharID].removedQuotes && DBState.db.characters[$selectedCharID].creatorNotes.length >= 2}
<CreatorQuote quote={DBState.db.characters[$selectedCharID].creatorNotes} onRemove={() => {
const cha = DBState.db.characters[$selectedCharID]
if(cha.type !== 'group'){
cha.removedQuotes = true
}
DBState.db.characters[$selectedCharID] = cha
}} />
{/if}
{/if} {/if}
</LazyPortal> </LazyPortal>
@@ -948,4 +950,5 @@
0% { transform: rotate(0deg); } 0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); } 100% { transform: rotate(360deg); }
} }
</style> </style>

View File

@@ -3,7 +3,6 @@
import { language } from "src/lang"; import { language } from "src/lang";
import Help from "src/lib/Others/Help.svelte"; import Help from "src/lib/Others/Help.svelte";
import { selectSingleFile } from "src/ts/util"; import { selectSingleFile } from "src/ts/util";
import { alertError } from "src/ts/alert";
import { DBState, selectedCharID } from 'src/ts/stores.svelte'; import { DBState, selectedCharID } from 'src/ts/stores.svelte';
import { isTauri, saveAsset, downloadFile } from "src/ts/globalApi.svelte"; import { isTauri, saveAsset, downloadFile } from "src/ts/globalApi.svelte";
import NumberInput from "src/lib/UI/GUI/NumberInput.svelte"; import NumberInput from "src/lib/UI/GUI/NumberInput.svelte";
@@ -42,7 +41,6 @@
autoSmea:false, autoSmea:false,
legacy_uc:false, legacy_uc:false,
use_coords:false, use_coords:false,
cfg_rescale:0,
v4_prompt:{ v4_prompt:{
caption:{ caption:{
base_caption:'', base_caption:'',
@@ -62,7 +60,6 @@
reference_strength_multiple: [0.7], reference_strength_multiple: [0.7],
vibe_data: undefined, vibe_data: undefined,
vibe_model_selection: undefined, vibe_model_selection: undefined,
noise_schedule: 'karras'
} }
if (DBState.db.NAIImgConfig.sampler === 'ddim_v3'){ if (DBState.db.NAIImgConfig.sampler === 'ddim_v3'){
DBState.db.NAIImgConfig.sm = false DBState.db.NAIImgConfig.sm = false

View File

@@ -12,7 +12,7 @@
} }
const { target: target = document.body, children, root, idx }:Props = $props(); const { target: target = document.body, children, root, idx }:Props = $props();
const paddingEle = document.createElement('div') let paddingEle = null
const context = getAllContexts(); const context = getAllContexts();
let instance; let instance;
@@ -20,21 +20,16 @@
onMount(() => { onMount(() => {
paddingEle.style.height = '48px';
paddingEle.style.width = '100%'
paddingEle.style.backgroundColor = '#ffffff'
paddingEle.style.color = 'black'
target.appendChild(paddingEle)
const observer = new IntersectionObserver((v) => { const observer = new IntersectionObserver((v) => {
if(v[0].intersectionRatio > 0.5){ if(v[0].intersectionRatio > 0.5){
seen = true seen = true
target.removeChild(paddingEle)
observer.disconnect() observer.disconnect()
} }
}, { }, {
threshold: 0.5, threshold: 0.5,
root: root,
}) })
observer.observe(target) observer.observe(target)
@@ -48,15 +43,14 @@
$effect(() => { $effect(() => {
if(seen){ if(seen){
try {
instance = mount(PortalConsumer, { target, props: { children }, context }) instance = mount(PortalConsumer, { target, props: { children }, context })
} catch (error) {}
} }
return () => { return () => {
if(instance){ if(instance){
unmount(instance); unmount(instance);
try {
target.removeChild(paddingEle)
} catch (error) {}
} }
} }
}); });

View File

@@ -4,4 +4,6 @@
{#if children} {#if children}
{@render children()} {@render children()}
{:else}
<div class="empty-portal"></div>
{/if} {/if}