Skip to content

Commit

Permalink
Add confirm dialog on load session. See #299.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasPause authored and KonradHoeffner committed Oct 1, 2020
1 parent 91ecacb commit 51598ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
30 changes: 19 additions & 11 deletions js/browser/file.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/** Module for loading files both locally from the server and via upload from the client.
@module */
import * as layout from "../layout.js";
import {View,views,reset,activeView} from "./view.js";
import {View,reset,activeView} from "./view.js";
import config from "../config.js";

/**
Uploads a JSON file from the user.
Expand Down Expand Up @@ -51,19 +52,26 @@ export const loadGraphFromJsonFile = graph => event =>
*/
export async function loadSessionFromJsonFile(event)
{
uploadJson(event,async json =>
if(config.multiview.warnOnSessionLoad)
{
reset();
const view=new View(false);
loadGraphFromJson(view.state.graph,json.mainGraph.graph);
activeView().setTitle(json.mainGraph.title);
for (let i =0; i<json.tabs.length;i++)
const hint = confirm('This will override the current session. Continue?');
if (hint)
{
const view = new View(false);
loadGraphFromJson(view.state.graph,json.tabs[i].graph);
activeView().setTitle(json.tabs[i].title);
uploadJson(event,async json =>
{
reset();
const view=new View(false);
loadGraphFromJson(view.state.graph,json.mainGraph.graph);
activeView().setTitle(json.mainGraph.title);
for (let i =0; i<json.tabs.length;i++)
{
const view = new View(false);
loadGraphFromJson(view.state.graph,json.tabs[i].graph);
activeView().setTitle(json.tabs[i].title);
}
});
}
});
}
}

/** Loads a stored view from a JSON file. */
Expand Down
1 change: 1 addition & 0 deletions js/config.dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ export default
"multiview":
{
"initialTabs": 1,
"warnOnSessionLoad": true,
},
};

0 comments on commit 51598ad

Please sign in to comment.