Skip to content

Commit 0ee0629

Browse files
committed
Don't warn about unsaved changes when deleting a scratch paper
1 parent cc7ea60 commit 0ee0629

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/frontend/components/App/index.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ class App extends React.Component {
123123
.catch(this.props.showErrorToast);
124124
}
125125

126-
loadAlgorithm({ categoryKey, algorithmKey, gistId }) {
127-
if (!this.isGistSaved() && !window.confirm('Are you sure want to discard changes?')) return;
126+
loadAlgorithm({ categoryKey, algorithmKey, gistId }, forceLoad = false) {
127+
if (!forceLoad && !this.isGistSaved() && !window.confirm('Are you sure want to discard changes?')) return;
128128

129129
const { ext } = this.props.env;
130130
let fetchPromise = null;
@@ -249,12 +249,12 @@ class App extends React.Component {
249249
</Helmet>
250250
<Header className={styles.header} onClickTitleBar={() => this.toggleNavigatorOpened()}
251251
navigatorOpened={navigatorOpened} loadScratchPapers={() => this.loadScratchPapers()}
252-
loadAlgorithm={params => this.loadAlgorithm(params)} gistSaved={gistSaved}
252+
loadAlgorithm={this.loadAlgorithm.bind(this)} gistSaved={gistSaved}
253253
file={file} />
254254
<ResizableContainer className={styles.workspace} horizontal weights={workspaceWeights}
255255
visibles={[navigatorOpened, true, true]}
256256
onChangeWeights={weights => this.handleChangeWorkspaceWeights(weights)}>
257-
<Navigator loadAlgorithm={params => this.loadAlgorithm(params)} />
257+
<Navigator loadAlgorithm={this.loadAlgorithm.bind(this)} />
258258
<VisualizationViewer className={styles.visualization_viewer} />
259259
<TabContainer className={styles.editor_tab_container} titles={editorTitles} tabIndex={editorTabIndex}
260260
onChangeTabIndex={tabIndex => this.handleChangeEditorTabIndex(tabIndex)}>

src/frontend/components/Header/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class Header extends React.Component {
6969
const { gistId } = this.props.current;
7070
const deletePromise = gistId === 'new' ? Promise.resolve() : GitHubApi.deleteGist(gistId);
7171
deletePromise
72-
.then(() => this.props.loadAlgorithm({}))
72+
.then(() => this.props.loadAlgorithm({}, true))
7373
.then(this.props.loadScratchPapers)
7474
.catch(this.props.showErrorToast);
7575
}

0 commit comments

Comments
 (0)