Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion frontend/webEditor/src/serialize/fileChooser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function getFiles(acceptedTypes: string[], amount: number): Promise<File[]> {
}
resolve(Array.from(input.files));
};

input.oncancel = () => {
reject("Canceled file selection");
};
});

input.click();
Expand All @@ -34,7 +38,7 @@ function readFile(file: File): Promise<FileData<string>> {
}

export async function chooseFiles(acceptedTypes: string[], amount: number): Promise<FileData<string>[]> {
const files = await getFiles(acceptedTypes, amount);
const files = await getFiles(acceptedTypes, amount).catch(() => [] as File[]);
return Promise.all(files.map(readFile));
}

Expand Down
5 changes: 4 additions & 1 deletion frontend/webEditor/src/serialize/loadJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
CommandReturn,
EMPTY_ROOT,
ILogger,
InitializeCanvasBoundsAction,
isLocateable,
SModelRootImpl,
SNodeImpl,
Expand Down Expand Up @@ -65,7 +66,8 @@ export abstract class LoadJsonCommand extends Command {
this.file = await this.getFile(context).catch(() => undefined);
if (!this.file) {
this.loadingIndicator.hide();
return context.root;
this.actionDispatcher.dispatch(InitializeCanvasBoundsAction.create(this.oldRoot.canvasBounds));
return this.oldRoot;
}

try {
Expand Down Expand Up @@ -111,6 +113,7 @@ export abstract class LoadJsonCommand extends Command {
} catch (error) {
this.logger.error(this, "Error loading model", error);
this.newRoot = this.oldRoot;
this.actionDispatcher.dispatch(InitializeCanvasBoundsAction.create(this.oldRoot.canvasBounds));
this.loadingIndicator.hide();
return this.oldRoot;
}
Expand Down