chore: format auth code and update runtime
This commit is contained in:
+3
-1
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user