Hotfix: planner init crashed for admin accounts, killing autosave and the plans list
Test and deploy / test-and-deploy (push) Successful in 1m34s
Test and deploy / test-and-deploy (push) Successful in 1m34s
The admin nav-link reveal ran before the generated nav existed
(getElementById('nav-admin') was null only for admins — which is why
tests and non-admin checks missed it), aborting init before form wiring,
autosave, and loadPlans. initSideNav now runs first, the reveal is
null-safe, and wireCuppingLink degrades instead of crashing (its button
lost its home when After-the-Roast moved — it now lives at the end of
the Roast Log section with a pointer to the Roasts page).
Also: the Roasts page graph now honors the planner's °C/°F preference.
Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5
parent
c6c392730f
commit
0b4857c225
+7
-2
@@ -1121,6 +1121,9 @@ function wireSectionNav() {
|
||||
}
|
||||
|
||||
async function init() {
|
||||
// The side nav is generated — render it before anything touches its elements (the admin
|
||||
// link reveal below crashed init for admin accounts when this ran later).
|
||||
initSideNav();
|
||||
try {
|
||||
const meResponse = await fetch("/api/auth/me");
|
||||
if (!meResponse.ok) {
|
||||
@@ -1132,7 +1135,7 @@ async function init() {
|
||||
document.getElementById("settings-email").textContent = user.email;
|
||||
applyAvatar(document.getElementById("nav-user-avatar"), user);
|
||||
if (user.role === "admin")
|
||||
document.getElementById("nav-admin").classList.remove("hidden");
|
||||
document.getElementById("nav-admin")?.classList.remove("hidden");
|
||||
const localDraft = loadFromStorage(user.id);
|
||||
state.plan = localDraft ?? blankPlan();
|
||||
const draftRemoteId = remotePlanId;
|
||||
@@ -1187,7 +1190,6 @@ async function init() {
|
||||
renderBandRanges();
|
||||
renderFormFromPlan();
|
||||
wireForm();
|
||||
initSideNav();
|
||||
wireDrawers();
|
||||
wireToolbar();
|
||||
wireToolsMenu();
|
||||
@@ -1225,6 +1227,9 @@ async function init() {
|
||||
function wireCuppingLink() {
|
||||
const button = document.getElementById("btn-open-cupping");
|
||||
const note = document.getElementById("cupping-link-note");
|
||||
// Defensive: this UI lives in the Roast Log section; a missing element must degrade to
|
||||
// "no cupping shortcut", never crash init (that failure mode silently killed autosave).
|
||||
if (!button || !note) return;
|
||||
button.addEventListener("click", async () => {
|
||||
button.disabled = true;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user