From f0e72945f32a48ca3dd6e9a5217adc597aa40846 Mon Sep 17 00:00:00 2001 From: Ayushya Amitabh Date: Wed, 6 May 2020 14:37:05 -0400 Subject: [PATCH] push listener fix --- src/VideoListener.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/VideoListener.js b/src/VideoListener.js index 8713008..37a551e 100644 --- a/src/VideoListener.js +++ b/src/VideoListener.js @@ -29,12 +29,30 @@ export default class VideoListener { Show Name: ${this.video.showName}\n Updating: ${this.isUpdating} `); - if (this.server.status !== this.video.status) { - if (this.video.showName && !this.isUpdating) this.listener(this.video); + if ( + this.server.status !== this.video.status || + Math.abs(this.server.time - this.video.element.currentTime) > 2 + ) { + if ( + this.video.showName && + !this.isUpdating && + (Math.abs(this.server.time - this.video.element.currentTime) > 2 || + this.server.status !== this.video.status) + ) { + this.listener(this.video); + } } } doUpdate(serverPlayer) { this.server = serverPlayer; + + console.log(` + Server Status: ${this.server.status}\n + Video Status: ${this.video.status}\n + Show Name: ${this.video.showName}\n + Updating: ${this.isUpdating} + `); + if (!this.isUpdating) { this.isUpdating = true; if (serverPlayer.updatedBy === window.localStorage.getItem('watchPartyUserUid')) {