Skip to content

Commit ba96a00

Browse files
committed
feat: initialize elements and files in INITIAL_APP_DATA and normalize canvas data on pad initialization
- Added `elements` and `files` properties to `INITIAL_APP_DATA` for better state management. - Updated the `usePad` hook to normalize canvas data before updating the scene, enhancing data consistency.
1 parent 91c5702 commit ba96a00

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/frontend/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export const INITIAL_APP_DATA = {
66
gridSize: 20,
77
gridStep: 5,
88
},
9+
elements: [],
10+
files: [],
911
};
1012

1113
// UI elements

src/frontend/src/hooks/usePadData.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export const usePad = (padId: string | null, excalidrawAPI: ExcalidrawImperative
4343
useEffect(() => {
4444
if (isTemporaryPad && excalidrawAPI) {
4545
console.debug(`[pad.ws] Initializing new temporary pad ${padId}`);
46-
excalidrawAPI.updateScene(INITIAL_APP_DATA);
46+
const normalizedData = normalizeCanvasData(INITIAL_APP_DATA);
47+
excalidrawAPI.updateScene(normalizedData);
4748
return;
4849
}
4950

0 commit comments

Comments
 (0)