aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-plugin.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/peertube-plugin.ts')
-rw-r--r--client/src/assets/player/peertube-plugin.ts13
1 files changed, 9 insertions, 4 deletions
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 {
13 getStoredVolume, 13 getStoredVolume,
14 saveLastSubtitle, 14 saveLastSubtitle,
15 saveMuteInStore, 15 saveMuteInStore,
16 saveVideoWatchHistory,
16 saveVolumeInStore 17 saveVolumeInStore
17} from './peertube-player-local-storage' 18} from './peertube-player-local-storage'
18 19
@@ -120,7 +121,7 @@ class PeerTubePlugin extends Plugin {
120 this.initializePlayer() 121 this.initializePlayer()
121 this.runViewAdd() 122 this.runViewAdd()
122 123
123 if (options.userWatching) this.runUserWatchVideo(options.userWatching) 124 this.runUserWatchVideo(options.userWatching, options.videoUUID)
124 }) 125 })
125 } 126 }
126 127
@@ -178,7 +179,7 @@ class PeerTubePlugin extends Plugin {
178 }, 1000) 179 }, 1000)
179 } 180 }
180 181
181 private runUserWatchVideo (options: UserWatching) { 182 private runUserWatchVideo (options: UserWatching, videoUUID: string) {
182 let lastCurrentTime = 0 183 let lastCurrentTime = 0
183 184
184 this.userWatchingVideoInterval = setInterval(() => { 185 this.userWatchingVideoInterval = setInterval(() => {
@@ -187,8 +188,12 @@ class PeerTubePlugin extends Plugin {
187 if (currentTime - lastCurrentTime >= 1) { 188 if (currentTime - lastCurrentTime >= 1) {
188 lastCurrentTime = currentTime 189 lastCurrentTime = currentTime
189 190
190 this.notifyUserIsWatching(currentTime, options.url, options.authorizationHeader) 191 if (options) {
191 .catch(err => console.error('Cannot notify user is watching.', err)) 192 this.notifyUserIsWatching(currentTime, options.url, options.authorizationHeader)
193 .catch(err => console.error('Cannot notify user is watching.', err))
194 } else {
195 saveVideoWatchHistory(videoUUID, currentTime)
196 }
192 } 197 }
193 }, this.CONSTANTS.USER_WATCHING_VIDEO_INTERVAL) 198 }, this.CONSTANTS.USER_WATCHING_VIDEO_INTERVAL)
194 } 199 }