Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix workspace reset functionality. #7106

Merged
merged 2 commits into from Aug 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
Copy link
Member

@vidartf vidartf Aug 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this save turned out to be redundant now, if you wanted to clean that up :)


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