Skip to content

Commit

Permalink
Merge pull request #7106 from afshin/reset-workspace
Browse files Browse the repository at this point in the history
Fix workspace reset functionality.
  • Loading branch information
blink1073 committed Aug 28, 2019
2 parents 105f7af + 2534251 commit 7f39762
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/apputils-extension/src/index.ts
Expand Up @@ -316,6 +316,9 @@ const state: JupyterFrontEndPlugin<IStateDB> = {
await workspaces.save(id, { data, metadata });
});

// Any time the local state database changes, save the workspace.
db.changed.connect(() => void save.invoke(), db);

commands.addCommand(CommandIDs.loadState, {
execute: async (args: IRouter.ILocation) => {
// Since the command can be executed an arbitrary number of times, make
Expand All @@ -340,9 +343,6 @@ const state: JupyterFrontEndPlugin<IStateDB> = {
return;
}

// Any time the local state database changes, save the workspace.
db.changed.connect(() => void save.invoke(), db);

try {
const saved = await workspaces.fetch(source);

Expand Down Expand Up @@ -422,7 +422,10 @@ const state: JupyterFrontEndPlugin<IStateDB> = {
delete query['reset'];

const url = path + URLExt.objectToQueryString(query) + hash;
const cleared = db.clear().then(() => router.stop);
const cleared = db
.clear()
.then(() => save.invoke())
.then(() => router.stop);

// After the state has been reset, navigate to the URL.
if (clone) {
Expand Down

0 comments on commit 7f39762

Please sign in to comment.