Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solid-panes",
"version": "4.5.2",
"version": "4.5.3",
"description": "Solid-compatible Panes: applets and views for the mashlib and databrowser",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
18 changes: 16 additions & 2 deletions src/mainPage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ import { createLeftSideMenu, refreshMenu } from './menu'
// so refreshUI can skip a full GotoSubject re-render when nothing changed.
const LAST_RENDER_ENV_KEY = '__lastRenderEnvSignature'

// Set once initMainPage has performed the initial (authenticated) render.
// refreshUI will not auto-GotoSubject before this flag is set, so early
// callers (e.g. mashlib's window 'load' -> syncEnvironmentToContext) cannot
// trigger a subject fetch before the auth session is active. See
// https://github.com/SolidOS/solid-logic/issues/324
const INITIAL_RENDER_KEY = '__initialRenderDone'

function renderEnvSignature (env?: RenderEnvironment): string {
if (!env) return ''
return [env.layout, env.theme, env.inputMode].join('|')
Expand Down Expand Up @@ -46,6 +53,7 @@ export async function initMainPage (
uri = uri || window.location.href
const subject: NamedNode = typeof uri === 'string' ? store.sym(uri) : uri
outliner.GotoSubject(subject, true, undefined, true, undefined)
;(outliner as any)[INITIAL_RENDER_KEY] = true

const header = await createHeader(store, outliner)
const menu = createLeftSideMenu(subject, outliner)
Expand All @@ -61,12 +69,18 @@ export async function refreshUI (outliner: OutlineManager) {
const pane = paneName ? paneRegistry?.byName?.(paneName) : undefined

// Only re-run GotoSubject (full pane re-render) when render-relevant
// environment fields actually changed since the last render.
// environment fields actually changed since the last render, and only
// after initMainPage has performed the initial render. Without the
// INITIAL_RENDER_KEY gate, pre-auth callers (e.g. mashlib's window
// 'load' -> refreshUI) could trigger a subject fetch before the auth
// session is active, 401-ing on private containers and leaving the pane
// stuck on a login/error state (SolidOS/solid-logic#324).
const initialRenderDone = (outliner as any)?.[INITIAL_RENDER_KEY] === true
const currentSignature = renderEnvSignature(outliner?.context?.environment)
const previousSignature = (outliner as any)?.[LAST_RENDER_ENV_KEY] ?? ''
const envChanged = currentSignature !== previousSignature

if (envChanged && store && typeof outliner?.GotoSubject === 'function') {
if (initialRenderDone && envChanged && store && typeof outliner?.GotoSubject === 'function') {
outliner.GotoSubject(store.sym(subjectUri), true, pane, true, undefined)
;(outliner as any)[LAST_RENDER_ENV_KEY] = currentSignature
}
Expand Down
Loading