restore elements on load from firebase (#2269)

This commit is contained in:
David Luzar 2020-10-26 15:45:51 +01:00 committed by GitHub
parent 46c421ee26
commit 915bda9fd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -2,6 +2,7 @@ import { createIV, getImportedKey } from "./index";
import { ExcalidrawElement } from "../element/types";
import { getSceneVersion } from "../element";
import Portal from "../components/Portal";
import { restoreElements } from "./restore";
let firebasePromise: Promise<typeof import("firebase/app")> | null = null;
@ -155,6 +156,5 @@ export async function loadFromFirebase(
const storedScene = doc.data() as FirebaseStoredScene;
const ciphertext = storedScene.ciphertext.toUint8Array();
const iv = storedScene.iv.toUint8Array();
const plaintext = await decryptElements(roomKey, iv, ciphertext);
return plaintext;
return restoreElements(await decryptElements(roomKey, iv, ciphertext));
}

View File

@ -35,7 +35,7 @@ const restoreElementWithProperties = <T extends ExcalidrawElement>(
// newly added elements
version: element.version || 1,
versionNonce: element.versionNonce ?? 0,
isDeleted: false,
isDeleted: element.isDeleted ?? false,
id: element.id || randomId(),
fillStyle: element.fillStyle || "hachure",
strokeWidth: element.strokeWidth || 1,