Make File Handling actually work (#2181)

Follow-up from #1736
This commit is contained in:
Thomas Steiner 2020-09-22 15:21:22 +02:00 committed by GitHub
parent 68bdfaefbe
commit b2822f3538
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 18 deletions

View file

@ -29,6 +29,7 @@ const loadFileContents = async (blob: any) => {
*/
export const loadFromBlob = async (blob: any, appState?: AppState) => {
if (blob.handle) {
// TODO: Make this part of `AppState`.
(window as any).handle = blob.handle;
}

View file

@ -66,9 +66,7 @@ export type SocketUpdateDataIncoming =
type: "INVALID_RESPONSE";
};
// TODO: Defined globally, since file handles aren't yet serializable.
// Once `FileSystemFileHandle` can be serialized, make this
// part of `AppState`.
// TODO: Make this part of `AppState`.
(window as any).handle = null;
const byteToHex = (byte: number): string => `0${byte.toString(16)}`.slice(-2);

View file

@ -33,6 +33,7 @@ export const saveAsJSON = async (
type: "application/json",
});
const name = `${appState.name}.excalidraw`;
// TODO: Make this part of `AppState`.
(window as any).handle = await fileSave(
blob,
{