From e0777cca587ffadf19c09caafd07eb406850e77f Mon Sep 17 00:00:00 2001 From: devleejb Date: Sat, 26 Oct 2024 22:27:39 +0900 Subject: [PATCH] Change default `syncLoopDuration` and Expose `yorkie.Document` --- frontend/src/hooks/useYorkieDocument.ts | 4 ++++ frontend/src/vite-env.d.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/frontend/src/hooks/useYorkieDocument.ts b/frontend/src/hooks/useYorkieDocument.ts index ef73d1d7..60cf4270 100644 --- a/frontend/src/hooks/useYorkieDocument.ts +++ b/frontend/src/hooks/useYorkieDocument.ts @@ -28,9 +28,11 @@ export const useYorkieDocument = ( }, [authStore.accessToken, searchParams]); const createYorkieClient = useCallback(async (yorkieToken: string) => { + const syncLoopDuration = Number(searchParams.get("syncLoopDuration")) || 200; const newClient = new yorkie.Client(YORKIE_API_ADDR, { apiKey: YORKIE_API_KEY, token: yorkieToken, + syncLoopDuration, }); await newClient.activate(); return newClient; @@ -88,6 +90,8 @@ export const useYorkieDocument = ( setClient(newClient); setDoc(newDoc); + // Expose the document to the window for debugging purposes + window.doc = newDoc; } catch (error) { console.error("Error initializing Yorkie: ", error); } diff --git a/frontend/src/vite-env.d.ts b/frontend/src/vite-env.d.ts index 11f02fe2..d8f07b7b 100755 --- a/frontend/src/vite-env.d.ts +++ b/frontend/src/vite-env.d.ts @@ -1 +1,4 @@ /// +interface Window { + doc: CodePairDocType; +}