Watch article history over SSE so the tab stays current while open.

This commit is contained in:
seb
2026-08-05 09:48:30 +02:00
parent 60e6858fd5
commit 44d69e541c
3 changed files with 75 additions and 4 deletions

View File

@@ -108,6 +108,12 @@ export class ApiClient {
get: (sku) => this.#json('GET', `/api/article/${enc(sku)}`),
/** GET /api/article/{sku}/history → { history: [{ id, date, text }, ...] } */
history: (sku) => this.#json('GET', `/api/article/${enc(sku)}/history`),
/**
* Load history and refetch on SSE `article-<sku>`.
* `onHistory(history)` / `onError(err)` — returns unwatch().
*/
historyWatch: (sku, onHistory, onError) =>
this.watchArticleHistory(sku, onHistory, onError),
/** PATCH /api/article/{sku} — body: at least one of { name, unitamount, unitSi } */
update: async (sku, body) => {
const nameChange = body != null && Object.hasOwn(body, 'name');