diff --git a/server/landing.ts b/server/landing.ts index aa4e475..f7f9678 100644 --- a/server/landing.ts +++ b/server/landing.ts @@ -242,9 +242,10 @@ export function renderMainLanding(modules: ModuleInfo[]): string { import '/shell.js'; document.querySelector('rstack-app-switcher')?.setModules(${moduleListJSON}); - // Logged-in users: hide header demo btn, swap hero CTA to "Go to My Space" + // Logged-in users: hide header demo btn, swap hero CTA + space switcher try { var raw = localStorage.getItem('encryptid_session'); + var sw = document.querySelector('rstack-space-switcher'); if (raw) { var session = JSON.parse(raw); var hdrBtn = document.querySelector('.rstack-header__demo-btn'); @@ -256,7 +257,10 @@ export function renderMainLanding(modules: ModuleInfo[]): string { primary.textContent = 'Go to My Space'; primary.href = 'https://' + username + '.rspace.online/rspace'; } + if (sw) { sw.setAttribute('current', username); sw.setAttribute('name', username + "'s Space"); } } + } else { + if (sw) { sw.setAttribute('current', 'demo'); sw.setAttribute('name', 'demo'); } } } catch(e) {} diff --git a/server/shell.ts b/server/shell.ts index edc043a..0ebad7d 100644 --- a/server/shell.ts +++ b/server/shell.ts @@ -2262,6 +2262,7 @@ export function renderModuleLanding(opts: ModuleLandingOptions): string { document.querySelector('rstack-app-switcher')?.setModules(${moduleListJSON}); try { var raw = localStorage.getItem('encryptid_session'); + var sw = document.querySelector('rstack-space-switcher'); if (raw) { var session = JSON.parse(raw); if (session?.claims?.username) { @@ -2271,7 +2272,10 @@ export function renderModuleLanding(opts: ModuleLandingOptions): string { primary.textContent = 'Go to My Space'; primary.href = 'https://' + username + '.rspace.online/${escapeAttr(mod.id)}'; } + if (sw) { sw.setAttribute('current', username); sw.setAttribute('name', username + "'s Space"); } } + } else { + if (sw) { sw.setAttribute('current', 'demo'); sw.setAttribute('name', 'demo'); } } } catch(e) {} @@ -2597,6 +2601,7 @@ export function renderSubPageInfo(opts: SubPageInfoOptions): string { document.querySelector('rstack-app-switcher')?.setModules(${moduleListJSON}); try { var raw = localStorage.getItem('encryptid_session'); + var sw = document.querySelector('rstack-space-switcher'); if (raw) { var session = JSON.parse(raw); if (session?.claims?.username) { @@ -2606,7 +2611,10 @@ export function renderSubPageInfo(opts: SubPageInfoOptions): string { primary.textContent = 'Open in My Space'; primary.href = 'https://' + username + '.rspace.online/${escapeAttr(mod.id)}/${escapeAttr(subPage.path)}'; } + if (sw) { sw.setAttribute('current', username); sw.setAttribute('name', username + "'s Space"); } } + } else { + if (sw) { sw.setAttribute('current', 'demo'); sw.setAttribute('name', 'demo'); } } } catch(e) {}