From e3a3f48fdc83fb247b25d02a2eca9d95b2720c4c Mon Sep 17 00:00:00 2001 From: Melvin Carvalho Date: Sun, 3 May 2026 09:07:01 +0200 Subject: [PATCH 1/2] mashlib: await xlogin ready before booting shell (#6) Hard-reload race: panes mounted before xlogin restored the session, so authenticated requests (e.g. sharing-pane) 401'd on first paint. Wait for the script to load and, when present, for window.xlogin.ready before importing the shell. Keeps losos/shell.js generic (no auth-library awareness in the framework). --- mashlib.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mashlib.js b/mashlib.js index bf18aff..b26faf9 100644 --- a/mashlib.js +++ b/mashlib.js @@ -20,6 +20,10 @@ document.head.appendChild(cssLink) // Inject xlogin for Solid/Nostr authentication var xloginScript = document.createElement('script') xloginScript.src = 'https://unpkg.com/xlogin' +var xloginLoaded = new Promise(r => { + xloginScript.addEventListener('load', r, { once: true }) + xloginScript.addEventListener('error', r, { once: true }) +}) document.head.appendChild(xloginScript) // Fetch the current resource @@ -81,5 +85,10 @@ for (var p of panes) { document.head.appendChild(el) } +// Wait for xlogin script to load + finish session restore so panes +// don't capture an unrestored auth state and 401 on hard reload. +await xloginLoaded +if (window.xlogin && window.xlogin.ready) await window.xlogin.ready + // Import shell — auto-boots on detecting
await import(base + 'losos/shell.js') From 1e641a3593c01bcce4d177f209c0a474b61edfe8 Mon Sep 17 00:00:00 2001 From: Melvin Carvalho Date: Sun, 3 May 2026 09:14:07 +0200 Subject: [PATCH 2/2] mashlib: drop verbose comment on xlogin awaits --- mashlib.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/mashlib.js b/mashlib.js index b26faf9..2470f00 100644 --- a/mashlib.js +++ b/mashlib.js @@ -85,8 +85,6 @@ for (var p of panes) { document.head.appendChild(el) } -// Wait for xlogin script to load + finish session restore so panes -// don't capture an unrestored auth state and 401 on hard reload. await xloginLoaded if (window.xlogin && window.xlogin.ready) await window.xlogin.ready