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.4.2-0",
"version": "4.4.2-1",
"description": "Solid-compatible Panes: applets and views for the mashlib and databrowser",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
28 changes: 21 additions & 7 deletions src/mainPage/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,17 @@ const applyMenuCollapsedState = (navMenu: HTMLElement | null): void => {
updateCollapseButtonPosition(navMenu, collapseBtn)
}

const isLoggedIn = (): boolean => Boolean(authSession?.info?.isLoggedIn)
const refreshAuthStateFromSession = async (): Promise<boolean> => {
try {
const webId = await authn.checkUser()
return Boolean(webId || authn.currentUser())
} catch {
// Keep the menu responsive even if auth refresh is transiently unavailable.
return Boolean(authn.currentUser())
}
}
Comment thread
Copilot marked this conversation as resolved.

const isLoggedIn = (): boolean => Boolean(authn.currentUser())

const setFooterVisibility = (loggedIn: boolean): void => {
const footer = document.querySelector('solid-ui-footer') as HTMLElement | null
Expand Down Expand Up @@ -343,6 +353,7 @@ export const createLeftSideMenu = async (subject: NamedNode, outliner: OutlineMa
const menuToggle = document.getElementById('MenuToggleBtn') as HTMLElement | null
const menuOverlay = document.getElementById('MenuOverlay') as HTMLElement | null
const navMenuContent = document.getElementById('NavMenuContent') as HTMLElement | null
await refreshAuthStateFromSession()

const closeMobileMenu = () => {
if (!navMenu || !menuToggle || !menuOverlay) return
Expand Down Expand Up @@ -445,20 +456,23 @@ export const createLeftSideMenu = async (subject: NamedNode, outliner: OutlineMa
await renderMenuItems(subject, outliner, navMenuContent)
}

authSession.events.on('login', () => {
authSession.events.on('login', async () => {
await refreshAuthStateFromSession()
updateMenuVisibility()
refreshMenu(outliner.context?.environment?.layout === 'mobile' ? 'mobile' : 'desktop')
refreshMenuItems()
await refreshMenuItems()
})
authSession.events.on('logout', () => {
authSession.events.on('logout', async () => {
await refreshAuthStateFromSession()
updateMenuVisibility()
refreshMenu(outliner.context?.environment?.layout === 'mobile' ? 'mobile' : 'desktop')
refreshMenuItems()
await refreshMenuItems()
})
authSession.events.on('sessionRestore', () => {
authSession.events.on('sessionRestore', async () => {
await refreshAuthStateFromSession()
updateMenuVisibility()
refreshMenu(outliner.context?.environment?.layout === 'mobile' ? 'mobile' : 'desktop')
refreshMenuItems()
await refreshMenuItems()
})
navMenuContent.dataset.authEventsBound = 'true'
}
Expand Down
Loading