Skip to content

Commit

Permalink
Don't create restore points until editor was opened once
Browse files Browse the repository at this point in the history
Avoid issues if PROJECT_CHANGED gets emitted without entering the editor
  • Loading branch information
GarboMuffin committed Aug 16, 2024
1 parent fb846ef commit 8a6d80f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/containers/tw-restore-point-manager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TWRestorePointManager extends React.Component {
// This helps reduce problems when people constantly enter and leave the editor which
// causes this component to re-mount. Still not perfect though, ideally we would
// compensate for time already passed.
if (this.props.projectChanged) {
if (this.props.projectChanged && this.props.hasEverEnteredEditor) {
this.queueRestorePoint();
}

Expand All @@ -90,7 +90,7 @@ class TWRestorePointManager extends React.Component {
}

handleProjectChanged () {
if (!this.timeout) {
if (this.props.hasEverEnteredEditor && !this.timeout) {
this.queueRestorePoint();
}
}
Expand Down Expand Up @@ -298,7 +298,10 @@ TWRestorePointManager.propTypes = {
loadingState: PropTypes.oneOf(LoadingStates).isRequired,
isShowingProject: PropTypes.bool.isRequired,
isModalVisible: PropTypes.bool.isRequired,
hasEverEnteredEditor: PropTypes.bool.isRequired,
vm: PropTypes.shape({
on: PropTypes.func.isRequired,
off: PropTypes.func.isRequired,
loadProject: PropTypes.func.isRequired,
stop: PropTypes.func.isRequired,
renderer: PropTypes.shape({
Expand All @@ -313,6 +316,7 @@ const mapStateToProps = state => ({
loadingState: state.scratchGui.projectState.loadingState,
isShowingProject: getIsShowingProject(state.scratchGui.projectState.loadingState),
isModalVisible: state.scratchGui.modals.restorePointModal,
hasEverEnteredEditor: state.scratchGui.mode.hasEverEnteredEditor,
vm: state.scratchGui.vm
});

Expand Down

0 comments on commit 8a6d80f

Please sign in to comment.