Skip to content

Commit

Permalink
Merge pull request #936 from Maxr1998/offline-listen-log-tweaks
Browse files Browse the repository at this point in the history
Use same logic for playback stop events and offline listen log
  • Loading branch information
Chaphasilor authored Oct 31, 2024
2 parents 9996889 + 4e1cfe9 commit 34cda03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/services/offline_listen_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class OfflineListenLogHelper {
/// The [timestamp] provided to this function should be in seconds
/// and marks the time the track was stopped.
Future<void> _logOfflineListen(OfflineListen listen) {
_logger.info("Storing offline listen for ${listen.name}");
return Future.wait([
Hive.box<OfflineListen>("OfflineListens").add(listen),
_exportOfflineListenToFile(listen)
Expand Down
14 changes: 8 additions & 6 deletions lib/services/playback_history_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,21 @@ class PlaybackHistoryService {
PlaybackState? previousState,
bool skippingForward,
) async {
final shouldReportPreviousTrack = previousItem != null &&
previousState != null &&
// don't submit stop events for idle tracks (at position 0 and not playing)
(previousState.playing ||
previousState.updatePosition != Duration.zero);

if (FinampSettingsHelper.finampSettings.isOffline) {
if (previousItem != null) {
if (shouldReportPreviousTrack) {
await _offlineListenLogHelper.logOfflineListen(previousItem.item);
}
return;
}

jellyfin_models.PlaybackProgressInfo? previousTrackPlaybackData;
if (previousItem != null &&
previousState != null &&
// don't submit stop events for idle tracks (at position 0 and not playing)
(previousState.playing ||
previousState.updatePosition != Duration.zero)) {
if (shouldReportPreviousTrack) {
previousTrackPlaybackData = generatePlaybackProgressInfoFromState(
previousItem,
previousState,
Expand Down

0 comments on commit 34cda03

Please sign in to comment.