chore: format auth code and update runtime

This commit is contained in:
2026-07-29 22:11:08 -04:00
parent 892479dceb
commit 22e6e721a7
9 changed files with 132 additions and 73 deletions
+3 -1
View File
@@ -37,7 +37,9 @@ document.querySelector("#save").addEventListener("click", async () => {
"content-type": "application/json",
"x-csrf-token": csrf(),
},
body: JSON.stringify({ enabled: document.querySelector("#signup").checked }),
body: JSON.stringify({
enabled: document.querySelector("#signup").checked,
}),
});
await load();
});
+3 -3
View File
@@ -19,6 +19,6 @@ form.addEventListener("submit", (event) => {
event.preventDefault();
submit("/api/auth/login");
});
document.querySelector("#signup").addEventListener("click", () =>
submit("/api/auth/signup"),
);
document
.querySelector("#signup")
.addEventListener("click", () => submit("/api/auth/signup"));
+6 -2
View File
@@ -409,7 +409,8 @@ function autosave() {
clearTimeout(autosave._t);
autosave._t = setTimeout(() => {
try {
if (storageKey) localStorage.setItem(storageKey, JSON.stringify(state.plan));
if (storageKey)
localStorage.setItem(storageKey, JSON.stringify(state.plan));
// Local storage is namespaced per authenticated account; the account copy is authoritative when online.
if (navigator.onLine && csrfToken()) {
const method = remotePlanId ? "PUT" : "POST";
@@ -455,7 +456,10 @@ function loadFromStorage(userId) {
// A shared browser must never retain a previous account's local-only draft.
for (let i = localStorage.length - 1; i >= 0; i--) {
const key = localStorage.key(i);
if ((key?.startsWith(`${STORAGE_PREFIX}:`) && key !== storageKey) || key === "roastPlannerPlan.v1")
if (
(key?.startsWith(`${STORAGE_PREFIX}:`) && key !== storageKey) ||
key === "roastPlannerPlan.v1"
)
localStorage.removeItem(key);
}
const raw = localStorage.getItem(storageKey);