UI overhaul, import fixes, fix user store

This commit is contained in:
2026-07-30 17:07:46 +02:00
parent 773149169b
commit 4b8bd11a4c
75 changed files with 1106 additions and 744 deletions

View File

@@ -56,21 +56,26 @@ let pages: Tab[] = [
},
]
let user: User = null
onMount(async () => {
user = await get_user()
load_page(window.location.pathname, false)
await load_page(window.location.pathname, false)
})
let current_page: Tab = $state(null)
const load_page = (pathname: string, history: boolean): boolean => {
const load_page = async (pathname: string, history: boolean): Promise<boolean> => {
console.debug(
"Page router: Navigating to page", pathname,
"current path", window.location.pathname,
"log history:", history,
)
let user: User
try {
user = await get_user()
} catch (err) {
alert("Failed to get user details: " + err)
}
const path_decoded = decodeURIComponent(pathname)
let page_by_path: Tab = null
let page_by_prefix: Tab = null
@@ -98,7 +103,7 @@ const load_page = (pathname: string, history: boolean): boolean => {
// If this page requires login, and the user is not logged in, then we
// redirect the user to the login page
if (current_page.login === true && (user.username === "" || user.username === undefined)) {
if (current_page.login === true && (user === null || user === undefined)) {
console.debug("User is not logged in, redirecting to login page", user)
return load_page("/login", true)
}