From 18c4e3d845b114b8594dcf837b5cdeca48477938 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Sat, 27 Sep 2025 11:03:21 +0800 Subject: [PATCH] fix(session): request aborted error when swtching sessions (cloudreve/cloudreve#2919) --- src/api/api.ts | 5 +++-- src/api/request.ts | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/api/api.ts b/src/api/api.ts index df87986..534e022 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -70,7 +70,7 @@ import { ViewerGroup, ViewerSessionResponse, } from "./explorer.ts"; -import { AppError, Code, CrHeaders, defaultOpts, send, ThunkResponse } from "./request.ts"; +import { AppError, Code, CrHeaders, defaultOpts, isRequestAbortedError, send, ThunkResponse } from "./request.ts"; import { CreateDavAccountService, DavAccount, ListDavAccountsResponse, ListDavAccountsService } from "./setting.ts"; import { ListShareResponse, ListShareService } from "./share.ts"; import { CaptchaResponse, SiteConfig } from "./site.ts"; @@ -115,7 +115,7 @@ export function getSiteConfig(section: string): ThunkResponse { }, { ...defaultOpts, - noCredential: section != "basic", + bypassSnackbar: (e) => isRequestAbortedError(e), errorSnackbarMsg: (e) => i18n.t("errLoadingSiteConfig", { ns: "common" }) + e.message, }, ), @@ -373,6 +373,7 @@ export function sendRenameFile(req: RenameFileService): ThunkResponse isRequestAbortedError(e), }, ), ); diff --git a/src/api/request.ts b/src/api/request.ts index ff3df73..bbb91d9 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -277,3 +277,7 @@ export function send( } }; } + +export const isRequestAbortedError = (e: Error) => { + return e.message == "Request aborted"; +};