fix: make account menu actions reliable
This commit is contained in:
+3
-8
@@ -595,7 +595,7 @@ function wireToolbar() {
|
||||
await protectedFetch("/api/auth/logout", { method: "POST" });
|
||||
} finally {
|
||||
clearDraft();
|
||||
location.assign("/");
|
||||
location.replace("/");
|
||||
}
|
||||
});
|
||||
document.getElementById("btn-add-actuator").addEventListener("click", () => {
|
||||
@@ -664,6 +664,8 @@ async function init() {
|
||||
return;
|
||||
}
|
||||
const { user } = await meResponse.json();
|
||||
if (user.role === "admin")
|
||||
document.getElementById("menu-admin").classList.remove("hidden");
|
||||
state.plan = loadFromStorage(user.id) ?? blankPlan();
|
||||
const response = await fetch("/api/plans");
|
||||
if (response.ok) {
|
||||
@@ -687,13 +689,6 @@ async function init() {
|
||||
wireToolbar();
|
||||
wirePwa();
|
||||
wireSectionNav();
|
||||
fetch("/api/auth/me")
|
||||
.then((r) => (r.ok ? r.json() : null))
|
||||
.then((body) => {
|
||||
if (body?.user?.role === "admin")
|
||||
document.getElementById("menu-admin").classList.remove("hidden");
|
||||
})
|
||||
.catch(() => {});
|
||||
initPrefillPanel({
|
||||
state,
|
||||
renderBlendRows: renderBlend,
|
||||
|
||||
Reference in New Issue
Block a user