Skip to content

Commit

Permalink
fix when localstorage empty
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigopivi committed Aug 22, 2018
1 parent 9491475 commit b9d08c8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions web/components/Editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,18 @@ export default class Editor extends React.Component<{}, IEditorState> {
});
flask.addLanguage('chatito', chatitoPrism);
flask.onUpdate(code => {
if (!this.tabs || !this.tabs[this.state.activeTabIndex]) {
return;
}
this.codeInputValue = code;
this.tabs[this.state.activeTabIndex].value = code;
// NOTE: ugly hack to know when codeflask is mounted (it makes 2 calls to update on mount)
this.editorUpdatesSetupCount < 2 ? this.editorUpdatesSetupCount++ : this.setState({ dataset: null });
this.debouncedTabDSLValidation();
if (this.editorUpdatesSetupCount < 2) {
this.editorUpdatesSetupCount++;
} else {
this.setState({ dataset: null });
this.debouncedTabDSLValidation();
}
});
flask.updateCode(this.tabs[this.state.activeTabIndex].value);
flask.setLineNumber();
Expand Down Expand Up @@ -379,6 +386,7 @@ export default class Editor extends React.Component<{}, IEditorState> {
this.tabs.push({ title: 'newFile.chatito', value: '' });
newActiveTabIndex = 0;
}
this.saveToLocalStorage(true, false, false);
this.changeTab(newActiveTabIndex);
};
};
Expand Down

0 comments on commit b9d08c8

Please sign in to comment.