fix: prevent raw app iframe reload on userStore refresh (#8455)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import RawAppBackgroundRunner from './RawAppBackgroundRunner.svelte'
|
||||
import type { Runnable } from './rawAppPolicy'
|
||||
import { htmlContent } from './utils'
|
||||
import { onMount } from 'svelte'
|
||||
import { onMount, untrack } from 'svelte'
|
||||
|
||||
interface Props {
|
||||
workspace: string
|
||||
@@ -26,10 +26,14 @@
|
||||
|
||||
// Use blob URL instead of srcDoc to give the iframe a proper origin.
|
||||
// srcDoc iframes have "null" origin which breaks URL constructor in routers.
|
||||
// untrack(user) so that userStore refreshes don't regenerate the blob URL
|
||||
// and cause the iframe to fully reload (losing all state).
|
||||
// The user context is only needed for initial render.
|
||||
let blobUrl = $derived.by(() => {
|
||||
if (!secret) return undefined
|
||||
const u = untrack(() => user)
|
||||
const baseUrl = typeof window !== 'undefined' ? window.location.origin : ''
|
||||
const html = htmlContent(workspace, secret, { ctx: user, workspace }, baseUrl, initialHash)
|
||||
const html = htmlContent(workspace, secret, { ctx: u, workspace }, baseUrl, initialHash)
|
||||
const blob = new Blob([html], { type: 'text/html' })
|
||||
return URL.createObjectURL(blob)
|
||||
})
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
import { syncTutorialsTodos } from '$lib/tutorialUtils'
|
||||
import { ArrowLeft, Search, WandSparkles } from 'lucide-svelte'
|
||||
import { getUserExt } from '$lib/user'
|
||||
import { deepEqual } from 'fast-equals'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import OperatorMenu from '$lib/components/sidebar/OperatorMenu.svelte'
|
||||
import GlobalSearchModal from '$lib/components/search/GlobalSearchModal.svelte'
|
||||
@@ -125,7 +126,9 @@
|
||||
console.error('Could not persist workspace to local storage', e)
|
||||
}
|
||||
const user = await getUserExt(workspace)
|
||||
userStore.set(user)
|
||||
if (!deepEqual(user, $userStore)) {
|
||||
userStore.set(user)
|
||||
}
|
||||
if (isCloudHosted() && user?.is_admin) {
|
||||
isPremiumStore.set(await WorkspaceService.getIsPremium({ workspace }))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user