X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Fpeertube-plugin.ts;h=07c7e33f6f8ff4ac004571f9e1d57da43437ffa4;hb=a45050e09edf6e2d74b6db48196f44ef9ce8fa58;hp=75a6e662ebec2c260f5e185efc28b24ebbaacb10;hpb=10f26f4203b8cef32778bf3435d8112eaea3c093;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/peertube-plugin.ts b/client/src/assets/player/peertube-plugin.ts index 75a6e662e..07c7e33f6 100644 --- a/client/src/assets/player/peertube-plugin.ts +++ b/client/src/assets/player/peertube-plugin.ts @@ -13,6 +13,7 @@ import { getStoredVolume, saveLastSubtitle, saveMuteInStore, + saveVideoWatchHistory, saveVolumeInStore } from './peertube-player-local-storage' @@ -120,7 +121,7 @@ class PeerTubePlugin extends Plugin { this.initializePlayer() this.runViewAdd() - if (options.userWatching) this.runUserWatchVideo(options.userWatching) + this.runUserWatchVideo(options.userWatching, options.videoUUID) }) } @@ -178,7 +179,7 @@ class PeerTubePlugin extends Plugin { }, 1000) } - private runUserWatchVideo (options: UserWatching) { + private runUserWatchVideo (options: UserWatching, videoUUID: string) { let lastCurrentTime = 0 this.userWatchingVideoInterval = setInterval(() => { @@ -187,8 +188,12 @@ class PeerTubePlugin extends Plugin { if (currentTime - lastCurrentTime >= 1) { lastCurrentTime = currentTime - this.notifyUserIsWatching(currentTime, options.url, options.authorizationHeader) - .catch(err => console.error('Cannot notify user is watching.', err)) + if (options) { + this.notifyUserIsWatching(currentTime, options.url, options.authorizationHeader) + .catch(err => console.error('Cannot notify user is watching.', err)) + } else { + saveVideoWatchHistory(videoUUID, currentTime) + } } }, this.CONSTANTS.USER_WATCHING_VIDEO_INTERVAL) }