From 9ead421b25e5323545b0b0f6f9a588f8c4db2dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Fern=C3=A1ndez?= Date: Thu, 4 Apr 2024 03:09:50 +0200 Subject: [PATCH] fix(playback): playback reporting (#2286) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to throttling, status events were being skipped. Fixes #2285 Signed-off-by: Fernando Fernández --- frontend/src/store/playback-manager.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/store/playback-manager.ts b/frontend/src/store/playback-manager.ts index b6ada16c40d..b8b481009b3 100644 --- a/frontend/src/store/playback-manager.ts +++ b/frontend/src/store/playback-manager.ts @@ -19,7 +19,7 @@ import { getItemsApi } from '@jellyfin/sdk/lib/utils/api/items-api'; import { getMediaInfoApi } from '@jellyfin/sdk/lib/utils/api/media-info-api'; import { getPlaystateApi } from '@jellyfin/sdk/lib/utils/api/playstate-api'; import { getTvShowsApi } from '@jellyfin/sdk/lib/utils/api/tv-shows-api'; -import { useEventListener, useThrottleFn } from '@vueuse/core'; +import { useEventListener, watchThrottled } from '@vueuse/core'; import { shuffle } from 'lodash-es'; import { v4 } from 'uuid'; import { watch, watchEffect } from 'vue'; @@ -471,8 +471,6 @@ class PlaybackManagerStore extends CommonStore { } }; - private readonly _reportPlaybackProgressThrottled = useThrottleFn(this._reportPlaybackProgress, this._progressReportInterval); - /** * Report playback stopped to the server. Used by the "Now playing" statistics in other clients. */ @@ -1246,7 +1244,12 @@ class PlaybackManagerStore extends CommonStore { } }); - watch(() => this.currentTime, this._reportPlaybackProgressThrottled); + watchThrottled( + () => this.currentTime, + this._reportPlaybackProgress, + { throttle: this._progressReportInterval } + ); + watch(() => this.status, this._reportPlaybackProgress); /** * Report playback stop when closing the tab