[#552] added check for ws status before write REST calls (#569)

Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
Camille Moussu
2026-02-23 11:21:54 +01:00
committed by GitHub
parent f40165d2e2
commit 5e9e52c8dd
4 changed files with 130 additions and 4 deletions
+8
View File
@@ -1,12 +1,16 @@
import { Auth } from "@/features/User/oidcAuth";
import { assertWebSocketAlive } from "@/websocket/connection/lifecycle/assertWebSocketAlive";
import ky from "ky";
import { getRetryDelay } from "./getRetryDelay";
const MUTATING_METHODS = new Set(["POST", "PUT", "PATCH", "DELETE"]);
const RETRY_CONFIG = {
maxRetries: 10,
initialDelay: 1000,
maxDelay: 120000,
};
export const api = ky.extend({
prefixUrl: window.CALENDAR_BASE_URL,
retry: {
@@ -28,6 +32,10 @@ export const api = ky.extend({
if (access_token) {
request.headers.set("Authorization", `Bearer ${access_token}`);
}
if (MUTATING_METHODS.has(request.method)) {
await assertWebSocketAlive();
}
return request;
},
],