Fix an incorrected finish which halted playback prematurely. The scenario was that there were events being rapidly added to the recording. (#606)

This commit is contained in:
Eoghan Murray
2021-06-30 15:39:00 +01:00
committed by GitHub
parent bf8d9d0f89
commit c1158d88df

View File

@@ -493,13 +493,16 @@ export class Replayer {
this.service.send({ type: 'CAST_EVENT', payload: { event } }); this.service.send({ type: 'CAST_EVENT', payload: { event } });
// events are kept sorted by timestamp, check if this is the last event // events are kept sorted by timestamp, check if this is the last event
let last_index = this.service.state.context.events.length - 1;
if ( if (
event === event ===
this.service.state.context.events[ this.service.state.context.events[last_index]
this.service.state.context.events.length - 1
]
) { ) {
const finish = () => { const finish = () => {
if (last_index < this.service.state.context.events.length - 1) {
// more events have been added since the setTimeout
return;
}
this.backToNormal(); this.backToNormal();
this.service.send('END'); this.service.send('END');
this.emitter.emit(ReplayerEvents.Finish); this.emitter.emit(ReplayerEvents.Finish);