refactor(ui): recent: add a quick button to remove item from recent

This commit is contained in:
Edouard Vanbelle
2026-07-20 01:10:04 +02:00
parent e3c3f6fe24
commit 63589e595e
19 changed files with 115 additions and 58 deletions
+17
View File
@@ -30,3 +30,20 @@ export async function clearRecent(): Promise<void> {
});
if (!res.ok) throw new Error(`clear recent failed: ${res.status}`);
}
/**
* Remove a single item from the caller's recent history — the "broom"
* per-row affordance in the recent view. Distinct from `clearRecent`
* (which wipes every entry). 404 means the item wasn't in recents to
* begin with — treated as a no-op success by the caller.
*/
export async function removeFromRecent(kind: ItemType, id: string): Promise<void> {
const res = await apiFetch(`/api/recent/${encodeURIComponent(kind)}/${encodeURIComponent(id)}`, {
method: 'DELETE',
credentials: 'same-origin',
headers: getCsrfHeaders()
});
if (!res.ok && res.status !== 404) {
throw new Error(`remove from recent failed: ${res.status}`);
}
}