aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-03-01 10:48:21 +0100
committerChocobozzz <me@florianbigard.com>2023-03-01 10:48:21 +0100
commit626b76dcf5df3d27628cd90053630cbbbbcccff0 (patch)
tree5eaf5dc44b43eda1d1e021731ee63afa388ba87c
parent43ae5745c3a8888eacc02bd94bb2523c7015cb0c (diff)
downloadPeerTube-626b76dcf5df3d27628cd90053630cbbbbcccff0.tar.gz
PeerTube-626b76dcf5df3d27628cd90053630cbbbbcccff0.tar.zst
PeerTube-626b76dcf5df3d27628cd90053630cbbbbcccff0.zip
Fix current video time saving for anonymous users
-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 })