From c1545b61149d4d6532d06d7360f3953fb4e9d1f6 Mon Sep 17 00:00:00 2001 From: seb Date: Wed, 5 Aug 2026 09:54:33 +0200 Subject: [PATCH] Have historyWatch report errors via notifyError instead of an onError callback. --- src/api/ApiClient.js | 5 ++--- src/api/StorageManager.js | 6 +++--- src/components/article/tabs/ArticleHistoryTab.jsx | 2 -- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/api/ApiClient.js b/src/api/ApiClient.js index 6e51612..8197ce3 100644 --- a/src/api/ApiClient.js +++ b/src/api/ApiClient.js @@ -110,10 +110,9 @@ export class ApiClient { history: (sku) => this.#json('GET', `/api/article/${enc(sku)}/history`), /** * Load history and refetch on SSE `article-`. - * `onHistory(history)` / `onError(err)` — returns unwatch(). + * `onHistory(history)` — returns unwatch(). Errors via notifyError. */ - historyWatch: (sku, onHistory, onError) => - this.watchArticleHistory(sku, onHistory, onError), + historyWatch: (sku, onHistory) => this.watchArticleHistory(sku, onHistory), /** PATCH /api/article/{sku} — body: at least one of { name, unitamount, unitSi } */ update: async (sku, body) => { const nameChange = body != null && Object.hasOwn(body, 'name'); diff --git a/src/api/StorageManager.js b/src/api/StorageManager.js index f26c21f..addbf35 100644 --- a/src/api/StorageManager.js +++ b/src/api/StorageManager.js @@ -1,4 +1,5 @@ import { requireArray, requireDefined, requireObject } from '../utils/apiShape'; +import { notifyError } from '../utils/notify'; import { ApiClient } from './ApiClient'; /** @@ -84,10 +85,9 @@ export class StorageManager extends ApiClient { * Fetch article history, then refetch whenever SSE emits `article-`. * @param {string} sku * @param {(history: unknown[]) => void} onHistory - * @param {(err: unknown) => void} onError * @returns {() => void} unwatch */ - watchArticleHistory(sku, onHistory, onError) { + watchArticleHistory(sku, onHistory) { const key = String(sku); let active = true; @@ -101,7 +101,7 @@ export class StorageManager extends ApiClient { const run = () => void refresh().catch((err) => { if (!active) return; - onError(err); + notifyError(err); }); let watchers = this.#historyWatchers.get(key); diff --git a/src/components/article/tabs/ArticleHistoryTab.jsx b/src/components/article/tabs/ArticleHistoryTab.jsx index 30ff34d..dd02bfd 100644 --- a/src/components/article/tabs/ArticleHistoryTab.jsx +++ b/src/components/article/tabs/ArticleHistoryTab.jsx @@ -5,7 +5,6 @@ import TableCell from '@mui/material/TableCell'; import TableHead from '@mui/material/TableHead'; import TableRow from '@mui/material/TableRow'; import { StorageManagerContext } from '../../../api/storageManagerContext'; -import { notifyError } from '../../../utils/notify'; function formatDate(iso) { return new Date(iso).toLocaleString('de-DE'); @@ -24,7 +23,6 @@ export default class ArticleHistoryTab extends Component { this.unwatchHistory = this.context.article.historyWatch( this.props.sku, (history) => this.setState({ history }), - notifyError, ); }