Normalize indices on init

This commit is contained in:
Marcel Mraz 2024-05-21 12:58:31 +01:00
parent 7b36de0476
commit e4c3744dc4
8 changed files with 112 additions and 31 deletions

View file

@ -18,6 +18,7 @@ import {
restoreElements,
zoomToFitBounds,
reconcileElements,
normalizeIndices,
} from "../../packages/excalidraw";
import type { Collaborator, Gesture } from "../../packages/excalidraw/types";
import {
@ -637,7 +638,16 @@ class Collab extends PureComponent<CollabProps, CollabState> {
fetchScene: true,
roomLinkData: existingRoomLinkData,
});
scenePromise.resolve(sceneData);
if (sceneData) {
scenePromise.resolve({
...sceneData,
// normalize fractional indices on init for shared scenes, while making sure there are no other collaborators
elements: normalizeIndices([...sceneData.elements]),
});
} else {
scenePromise.resolve(null);
}
});
this.portal.socket.on(