Skip to content

Commit

Permalink
fix(playback): playback reporting (#2286)
Browse files Browse the repository at this point in the history
Due to throttling, status events were being skipped.

Fixes #2285
Signed-off-by: Fernando Fernández <[email protected]>
  • Loading branch information
ferferga authored Apr 4, 2024
1 parent 40b3fd2 commit 9ead421
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions frontend/src/store/playback-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ead421

Please sign in to comment.