Skip to content

Commit

Permalink
Merge pull request #349 from NeurodataWithoutBorders/ensure-pages-alw…
Browse files Browse the repository at this point in the history
…ays-save-once

Ensure pages always save once
  • Loading branch information
CodyCBakerPhD authored Sep 14, 2023
2 parents e2d00c4 + 474b555 commit c83b4d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/renderer/src/stories/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,13 @@ export class Dashboard extends LitElement {
pageState = state.pages[id] = {
visited: false,
active: false,
saved: false,
pageLabel: page.info.label,
pageTitle: page.info.title,
};

info.states = pageState;

state.active = false;
pageState.active = false;

Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/stories/pages/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Page extends LitElement {
this.beforeTransition();

// Otherwise note unsaved updates if present
if (this.unsavedUpdates) {
if (this.unsavedUpdates || this.info.states?.saved) {
if (transition === 1) await this.save(); // Save before a single forward transition
else {
Swal.fire({
Expand Down Expand Up @@ -95,6 +95,7 @@ export class Page extends LitElement {
save = async (overrides, runBeforeSave = true) => {
if (runBeforeSave) await this.beforeSave();
save(this, overrides);
this.info.states.saved = true;
this.unsavedUpdates = false;
};

Expand Down

0 comments on commit c83b4d7

Please sign in to comment.