From 5f47edc984f1d3a11b599ec9adbb47a092a10af2 Mon Sep 17 00:00:00 2001 From: LeeJongBeom <52884648+devleejb@users.noreply.github.com> Date: Sat, 26 Oct 2024 22:30:10 +0900 Subject: [PATCH] Change default `syncLoopDuration` and Expose `yorkie.Document` (#386) --- 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; +}