From 626b76dcf5df3d27628cd90053630cbbbbcccff0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 1 Mar 2023 10:48:21 +0100 Subject: Fix current video time saving for anonymous users --- .../assets/player/shared/peertube/peertube-plugin.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'client/src/assets') diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index b5f177f30..da9b3bd0e 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts @@ -207,26 +207,20 @@ class PeerTubePlugin extends Plugin { .catch(err => logger.error('Cannot notify user is watching.', err)) lastViewEvent = undefined - - // Server won't save history, so save the video position in local storage - if (!this.authorizationHeader()) { - saveVideoWatchHistory(this.videoUUID, currentTime) - } }, this.videoViewIntervalMs) } private notifyUserIsWatching (currentTime: number, viewEvent: VideoViewEvent) { - if (!this.videoViewUrl) return Promise.resolve(undefined) - - const body: VideoView = { - currentTime, - viewEvent + // Server won't save history, so save the video position in local storage + if (!this.authorizationHeader()) { + saveVideoWatchHistory(this.videoUUID, currentTime) } - const headers = new Headers({ - 'Content-type': 'application/json; charset=UTF-8' - }) + if (!this.videoViewUrl) return + + const body: VideoView = { currentTime, viewEvent } + const headers = new Headers({ 'Content-type': 'application/json; charset=UTF-8' }) if (this.authorizationHeader()) headers.set('Authorization', this.authorizationHeader()) return fetch(this.videoViewUrl, { method: 'POST', body: JSON.stringify(body), headers }) -- cgit v1.2.3