aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/assets/player/shared/peertube/peertube-plugin.ts20
1 files changed, 7 insertions, 13 deletions
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 {
207 .catch(err => logger.error('Cannot notify user is watching.', err)) 207 .catch(err => logger.error('Cannot notify user is watching.', err))
208 208
209 lastViewEvent = undefined 209 lastViewEvent = undefined
210
211 // Server won't save history, so save the video position in local storage
212 if (!this.authorizationHeader()) {
213 saveVideoWatchHistory(this.videoUUID, currentTime)
214 }
215 }, this.videoViewIntervalMs) 210 }, this.videoViewIntervalMs)
216 } 211 }
217 212
218 private notifyUserIsWatching (currentTime: number, viewEvent: VideoViewEvent) { 213 private notifyUserIsWatching (currentTime: number, viewEvent: VideoViewEvent) {
219 if (!this.videoViewUrl) return Promise.resolve(undefined) 214 // Server won't save history, so save the video position in local storage
220 215 if (!this.authorizationHeader()) {
221 const body: VideoView = { 216 saveVideoWatchHistory(this.videoUUID, currentTime)
222 currentTime,
223 viewEvent
224 } 217 }
225 218
226 const headers = new Headers({ 219 if (!this.videoViewUrl) return
227 'Content-type': 'application/json; charset=UTF-8' 220
228 }) 221 const body: VideoView = { currentTime, viewEvent }
229 222
223 const headers = new Headers({ 'Content-type': 'application/json; charset=UTF-8' })
230 if (this.authorizationHeader()) headers.set('Authorization', this.authorizationHeader()) 224 if (this.authorizationHeader()) headers.set('Authorization', this.authorizationHeader())
231 225
232 return fetch(this.videoViewUrl, { method: 'POST', body: JSON.stringify(body), headers }) 226 return fetch(this.videoViewUrl, { method: 'POST', body: JSON.stringify(body), headers })