fix: omit status on non-archive writes, skip finished in refresh and scan

This commit is contained in:
2026-07-27 13:35:46 +07:00
parent 896792d504
commit 7a16abd6a3
4 changed files with 83 additions and 6 deletions
+10 -3
View File
@@ -271,11 +271,17 @@
return res.json();
}
async function apiPut(key, obj) {
// Only an explicit archive/restore has an opinion about the bucket. Every
// other write omits `status`, so the server keeps the stored one — otherwise
// a cached value would resend "finished" (which the API rejects with 400) or
// silently un-archive a series archived on another device.
async function apiPut(key, obj, { sendStatus = false } = {}) {
const body = Object.assign({}, obj);
if (!sendStatus) delete body.status;
const res = await fetch(API_BASE + "/bookmarks/" + encodeURIComponent(key), {
method: "PUT",
headers: authHeaders({ "Content-Type": "application/json" }),
body: JSON.stringify(obj),
body: JSON.stringify(body),
});
if (!res.ok) throw new Error("PUT /bookmarks " + res.status);
return res.json();
@@ -433,7 +439,7 @@
upsertLocal(bm);
render();
try {
const saved = await apiPut(bm.key, bm);
const saved = await apiPut(bm.key, bm, { sendStatus: true });
upsertLocal(saved); // adopt the stored row: the server owns updated_at
render();
toast(next === "archived" ? "Archived" : "Back in your list");
@@ -489,6 +495,7 @@
const now = Date.now();
const due = state.list
.filter((b) => b.site === site && b.series_url)
.filter((b) => statusOf(b) !== "finished")
.filter((b) => now - (checked[b.key] || 0) >= LATEST_CHECK_THROTTLE_MS)
.sort((a, b) => (checked[a.key] || 0) - (checked[b.key] || 0))
.slice(0, LATEST_CHECK_BATCH);