updated code comments and fixed checkApiError legacy calls
This commit is contained in:
@@ -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
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 "";
|
||||
|
||||
Reference in New Issue
Block a user