Several improvements to tldraw whiteboard:
- Only send the shape diff on shape updates (reduce a lot the message traffic)
- Shape permissions (don't allow others to select/edit unless you are presenter/moderator)
- This required some changes in akka model
- Tldraw state patch changes to improve stability with fast updates (fix several crashes)
Sometimes when whiteboard props change (mainly resizes), the tldraw component gets
mounted again, resetting its camera, and was causing zoom to be applied incorrectly.
I've added a useEffect to better react to when the camera resets and reset to the corret zoom.
- For presenter/multiuser Don't allow selecting the background shape (could be done with right click on empty area)
- For viewers: don't allow selecting anything (also hides the selection brush)
Refactor how shape updates are parsed from tldraw, instead of doing it manually in each action,
uses the tldraw provided list of what changed available in the "onChangePage" callback, simplifying a lot of our code.
- Return to the ResizeAndMoveSlide event to do pan&zoom, respecting the viewed width and height ratio
- Defaults zoom in toolbar to 100% like before to be more consistent
- Fit to width and Reset Zoom is back (fit tho width still has some sync problems)
- Fix to not change to first page when presenter reloads page
Fixes a case when the presentation is just uploaded and a wrong initial zoom was set.
Also fix viewer zoom not correclty adjusting to the area size when zoomed out.
Tldraw uses the constructor name for session complete names:
80ed0bf27b/packages/tldraw/src/state/TldrawApp.ts (L2916)
So in production they are changed because of js minifier.
I changed the onCommand reactor to be one generic for all session:complete actions.
Also fixed some crashes with grouping and ungrouping shapes, in those cases the order of adding/removing is important because children have a reference to the father (grouping shape).