updated code comments and fixed checkApiError legacy calls

This commit is contained in:
Gani Georgiev
2026-06-02 14:04:47 +03:00
parent 40d2849aa6
commit e5964e739e
11 changed files with 26 additions and 24 deletions
+4 -4
View File
@@ -31,13 +31,13 @@ export function docsListAuthMethods(collection) {
try {
data.authMethods = await app.pb.collection(collection.name).listAuthMethods();
data.isLoading = false;
} catch (err) {
if (err.isAbort) {
app.pb.checkApiError(err);
if (!err?.isAbort) {
app.checkApiError(err);
data.isLoading = false;
}
}
data.isLoading = false;
}
return t.div(
+4 -8
View File
@@ -180,13 +180,9 @@ async function fetchFileToken() {
});
}
// Generic API error handler
// -------------------------------------------------------------------
/**
* Helper to parse a response error and to show an optional toast message.
* In case of 401 it clears the auth store and redirects to the home page.
* In case of 403 it redirects to the home or login page.
* Generic API error handler that loads the response error into the app store
* with the option to show a generic toast message.
*
* Example:
*
@@ -200,8 +196,8 @@ async function fetchFileToken() {
* }
* ```
*
* @param {Error} err
* @param {boolean} showToast
* @param {Error} err
* @param {boolean} [showToast]
*/
window.app.checkApiError = function(err, showToast = true) {
if (!err || !(err instanceof Error) || err.isAbort) {
+2 -2
View File
@@ -1355,8 +1355,8 @@ function authProvidersTab(collection, data) {
local.isLoading = false;
} catch (err) {
if (err?.isAbort) {
app.pb.checkApiError(err);
if (!err?.isAbort) {
app.checkApiError(err);
local.isLoading = false;
}
}
+6
View File
@@ -717,6 +717,12 @@ const utils = {
return date.toISOString().replace("T", " ");
},
/**
* Returns datetime formatted string (YYYY-MM-DD HH:mm:ss.nnn) in the local timezone.
*
* @param {string|number|Date} strOrDate
* @return {string}
*/
toLocalDatetime(strOrDate) {
if (!strOrDate) {
return "";