Skip to content

Commit 556193c

Browse files
committed
refactor: move collaboration constants for pointer throttling and periodic sync to constants.ts
1 parent ba96a00 commit 556193c

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/frontend/src/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ export const HIDDEN_UI_ELEMENTS = {
2020
sidebar: true,
2121
};
2222

23+
// Collab constants
24+
export const POINTER_MOVE_THROTTLE_MS = 30; // Throttle pointer move events to reduce the number of updates sent to the server
25+
export const ENABLE_PERIODIC_FULL_SYNC = false; // Set to false to disable periodic scene_update full sync
26+
export const PERIODIC_FULL_SYNC_INTERVAL_MS = 60000; // Sync scene_update every 60 seconds if ENABLE_PERIODIC_FULL_SYNC is true

src/frontend/src/lib/collab/Collab.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import {
55
viewportCoordsToSceneCoords,
66
getSceneVersion,
77
reconcileElements,
8-
restoreElements,
9-
getVisibleSceneBounds,
10-
zoomToFitBounds
8+
restoreElements
119
} from '@atyrode/excalidraw';
1210
import throttle from 'lodash.throttle';
1311
import isEqual from 'lodash.isequal';
@@ -16,6 +14,7 @@ import Portal from './Portal';
1614
import type { WebSocketMessage, ConnectionStatus } from './Portal';
1715
import type { UserInfo } from '../../hooks/useAuthStatus';
1816
import { debounce, type DebouncedFunction } from '../debounce';
17+
import { POINTER_MOVE_THROTTLE_MS, ENABLE_PERIODIC_FULL_SYNC, PERIODIC_FULL_SYNC_INTERVAL_MS } from '../../constants';
1918

2019
interface PointerData {
2120
x: number;
@@ -61,12 +60,6 @@ interface CollabState {
6160
lastProcessedSceneVersion: number;
6261
}
6362

64-
const POINTER_MOVE_THROTTLE_MS = 20;
65-
66-
// Constants for periodic full scene sync
67-
const ENABLE_PERIODIC_FULL_SYNC = false; // Set to false to disable periodic full sync
68-
const PERIODIC_FULL_SYNC_INTERVAL_MS = 60000; // Sync every 60 seconds (adjust as needed)
69-
7063
class Collab extends PureComponent<CollabProps, CollabState> {
7164
[x: string]: any;
7265
readonly state: CollabState;

0 commit comments

Comments
 (0)