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
|
@ -30,21 +30,25 @@ export type EncryptedData = {
|
|||
iv: Uint8Array;
|
||||
};
|
||||
|
||||
export type SocketUpdateData =
|
||||
| {
|
||||
type: "SCENE_UPDATE";
|
||||
payload: {
|
||||
elements: readonly ExcalidrawElement[];
|
||||
appState: AppState | null;
|
||||
};
|
||||
}
|
||||
| {
|
||||
type: "MOUSE_LOCATION";
|
||||
payload: {
|
||||
socketID: string;
|
||||
pointerCoords: { x: number; y: number };
|
||||
};
|
||||
}
|
||||
export type SocketUpdateDataSource = {
|
||||
SCENE_UPDATE: {
|
||||
type: "SCENE_UPDATE";
|
||||
payload: {
|
||||
elements: readonly ExcalidrawElement[];
|
||||
appState: Pick<AppState, "viewBackgroundColor" | "name" | "deletedIds">;
|
||||
};
|
||||
};
|
||||
MOUSE_LOCATION: {
|
||||
type: "MOUSE_LOCATION";
|
||||
payload: {
|
||||
socketID: string;
|
||||
pointerCoords: { x: number; y: number };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export type SocketUpdateDataIncoming =
|
||||
| SocketUpdateDataSource[keyof SocketUpdateDataSource]
|
||||
| {
|
||||
type: "INVALID_RESPONSE";
|
||||
};
|
||||
|
@ -137,7 +141,7 @@ export async function decryptAESGEM(
|
|||
data: ArrayBuffer,
|
||||
key: string,
|
||||
iv: Uint8Array,
|
||||
): Promise<SocketUpdateData> {
|
||||
): Promise<SocketUpdateDataIncoming> {
|
||||
try {
|
||||
const importedKey = await getImportedKey(key, "decrypt");
|
||||
const decrypted = await window.crypto.subtle.decrypt(
|
||||
|
|
|
@ -52,7 +52,7 @@ export function restore(
|
|||
|
||||
return {
|
||||
...element,
|
||||
version: element.id ? element.version + 1 : element.version || 0,
|
||||
version: element.version || 0,
|
||||
id: element.id || nanoid(),
|
||||
fillStyle: element.fillStyle || "hachure",
|
||||
strokeWidth: element.strokeWidth || 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue