Custom room, various fixes

This commit is contained in:
Marcel Mraz 2024-12-31 12:49:23 +01:00
parent e72d83541a
commit c57249481e
No known key found for this signature in database
GPG key ID: 4EBD6E62DC830CD2
3 changed files with 44 additions and 38 deletions

View file

@ -856,7 +856,7 @@ const ExcalidrawWrapper = () => {
excalidrawAPI?.updateScene({
appState: {
...excalidrawAPI?.getAppState(),
viewModeEnabled: value !== acknowledgedIncrements.length,
viewModeEnabled: value !== -1,
},
elements: Array.from(elements.values()),
storeAction: StoreAction.UPDATE,
@ -865,7 +865,7 @@ const ExcalidrawWrapper = () => {
currentVersion.current = value;
}, 0);
const latestVersion = acknowledgedIncrements.length - 1;
const latestVersion = acknowledgedIncrements.length;
return (
<div
@ -885,24 +885,24 @@ const ExcalidrawWrapper = () => {
step={1}
min={0}
max={latestVersion}
value={
nextVersion === -1 || nextVersion === latestVersion
? latestVersion
: nextVersion
}
value={nextVersion === -1 ? latestVersion : nextVersion}
onChange={(value) => {
let nextValue: number;
// CFDO: should be disabled when offline! (later we could have speculative changes in the versioning log as well)
// CFDO: in safari the whole canvas gets selected when dragging
if (value !== acknowledgedIncrements.length) {
// don't listen to updates in the detached mode
syncAPI?.disconnect();
nextValue = value as number;
} else {
// reconnect once we're back to the latest version
syncAPI?.connect();
nextValue = -1;
}
setNextVersion(value as number);
debouncedTimeTravel(value as number);
setNextVersion(nextValue);
debouncedTimeTravel(nextValue);
}}
/>
<Excalidraw