Encapsulate SceneHistory. A little. (#1016)

pull/1029/head
Kent Beck 5 years ago committed by GitHub
parent 46e619d800
commit dc618ab122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2432,10 +2432,7 @@ export class App extends React.Component<any, AppState> {
this.broadcastSceneUpdate();
}
if (history.isRecording()) {
history.pushEntry(this.state, globalSceneState.getAllElements());
history.skipRecording();
}
history.record(this.state, globalSceneState.getAllElements());
}
}

@ -123,17 +123,17 @@ export class SceneHistory {
return null;
}
isRecording() {
return this.recording;
}
skipRecording() {
this.recording = false;
}
// Suspicious that this is called so many places. Seems error-prone.
resumeRecording() {
this.recording = true;
}
record(state: AppState, elements: readonly ExcalidrawElement[]) {
if (this.recording) {
this.pushEntry(state, elements);
this.recording = false;
}
}
}
export const createHistory: () => { history: SceneHistory } = () => {

Loading…
Cancel
Save