retain local appState props on restore (#2224)

Co-authored-by: Lipis <lipiridis@gmail.com>
This commit is contained in:
David Luzar
2020-10-13 13:46:52 +02:00
committed by GitHub
parent b91f929503
commit 7618ca48d7
9 changed files with 153 additions and 69 deletions

View File

@@ -1,7 +1,7 @@
import { ExcalidrawElement } from "../element/types";
import { AppState, LibraryItems } from "../types";
import { clearAppStateForLocalStorage, getDefaultAppState } from "../appState";
import { restore } from "./restore";
import { restoreElements } from "./restore";
const LOCAL_STORAGE_KEY = "excalidraw";
const LOCAL_STORAGE_KEY_STATE = "excalidraw-state";
@@ -21,8 +21,8 @@ export const loadLibrary = (): Promise<LibraryItems> => {
return resolve([]);
}
const items = (JSON.parse(data) as LibraryItems).map(
(elements) => restore({ elements, appState: null }).elements,
const items = (JSON.parse(data) as LibraryItems).map((elements) =>
restoreElements(elements),
) as Mutable<LibraryItems>;
// clone to ensure we don't mutate the cached library elements in the app