mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
use deletedIds map to sync deletions (#936)
* use deletedIds map for sync deletions * refactor how we create data for syncing * fix comments * streamline broadcast API * split broadcast methods
This commit is contained in:
parent
ead6a083d4
commit
b9c75b5bc4
6 changed files with 128 additions and 68 deletions
|
@ -34,11 +34,24 @@ export function deleteSelectedElements(
|
|||
elements: readonly ExcalidrawElement[],
|
||||
appState: AppState,
|
||||
) {
|
||||
const deletedIds: AppState["deletedIds"] = {};
|
||||
return {
|
||||
elements: elements.filter(el => !appState.selectedElementIds[el.id]),
|
||||
elements: elements.filter(el => {
|
||||
if (appState.selectedElementIds[el.id]) {
|
||||
deletedIds[el.id] = {
|
||||
version: el.version,
|
||||
};
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
appState: {
|
||||
...appState,
|
||||
selectedElementIds: {},
|
||||
deletedIds: {
|
||||
...appState.deletedIds,
|
||||
...deletedIds,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue