From fbfb96297d6d4a07a99a75aec127c2d2bccbd338 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Sat, 17 Apr 2021 16:34:06 +0800 Subject: [PATCH] fix first play check --- src/replay/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index 9e4c574e..8cdada96 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -119,10 +119,10 @@ export class Replayer { private elementStateMap!: Map; private imageMap: Map = new Map(); - + /** The first time the player is playing. */ - private firstPlay = true; - + private firstPlayedEvent: eventWithTime | null = null; + private newDocumentQueue: addedNodeMutation[] = []; constructor( @@ -250,9 +250,10 @@ export class Replayer { if (firstFullsnapshot) { setTimeout(() => { // when something has been played, there is no need to rebuild poster - if (this.timer.timeOffset > 0) { + if (this.firstPlayedEvent) { return; } + this.firstPlayedEvent = firstFullsnapshot; this.rebuildFullSnapshot( firstFullsnapshot as fullSnapshotEvent & { timestamp: number }, ); @@ -463,8 +464,7 @@ export class Replayer { case EventType.FullSnapshot: castFn = () => { // Don't build a full snapshot during the first play through since we've already built it when the player was mounted. - if (this.firstPlay) { - this.firstPlay = false; + if (this.firstPlayedEvent && this.firstPlayedEvent === event) { return; } this.rebuildFullSnapshot(event, isSync);