This commit is contained in:
seb
2026-08-05 20:15:39 +02:00
parent ff79d5b92c
commit caf08a3262
3 changed files with 76 additions and 14 deletions

View File

@@ -118,11 +118,19 @@ export class ApiClient {
const nameChange = body != null && Object.hasOwn(body, 'name');
if (nameChange) {
this.setArticleIndexName(sku, body.name);
this.setArticleName(sku, body.name);
}
try {
return await this.#json('PATCH', `/api/article/${enc(sku)}`, { body });
const res = await this.#json('PATCH', `/api/article/${enc(sku)}`, { body });
this.setArticle(res.article);
return res;
} catch (err) {
if (nameChange) this.clearArticleIndex();
if (nameChange) {
this.clearArticleIndex();
if (this.getArticle(sku)) {
void this.loadArticle(sku).catch(() => {});
}
}
throw err;
}
},