fix(playback): playback reporting (#2286)

Due to throttling, status events were being skipped.

Fixes #2285
Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
This commit is contained in:
Fernando Fernández 2024-04-04 03:09:50 +02:00 committed by GitHub
parent 40b3fd2797
commit 9ead421b25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<PlaybackManagerState> {
}
};
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<PlaybackManagerState> {
}
});
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