From 8cbacb9aa72242cd301cfd62ed2b847ea2164b00 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Fri, 25 Jul 2025 13:30:26 +0200 Subject: [PATCH] Allow silencing API request errors. The {silent: true} option in the new `opts` argument to the `api` action does the trick. --- lib/www/client/source/src/store/modules/api/actions.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/www/client/source/src/store/modules/api/actions.js b/lib/www/client/source/src/store/modules/api/actions.js index 459f308..1c0ff8e 100644 --- a/lib/www/client/source/src/store/modules/api/actions.js +++ b/lib/www/client/source/src/store/modules/api/actions.js @@ -1,5 +1,5 @@ -async function api ({state, getters, commit, dispatch}, [resource, init = {}, cb]) { +async function api ({state, getters, commit, dispatch}, [resource, init = {}, cb, opts = {}]) { try { commit("queueRequest"); if (init && init.hasOwnProperty("body")) { @@ -49,7 +49,9 @@ async function api ({state, getters, commit, dispatch}, [resource, init = {}, cb message = body.message; } } - await dispatch('showSnack', [message, "warning"]); + if (!opts?.silent) { + await dispatch('showSnack', [message, "warning"]); + } } } catch (err) { if (err && err.name == "AbortError") return;