Skip to content

Commit

Permalink
fix stop events sometimes not being logged in offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaphasilor committed Dec 11, 2024
1 parent ea1bbf6 commit 7791ee6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/services/playback_history_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -461,20 +461,18 @@ class PlaybackHistoryService {
}

Future<void> _reportPlaybackStopped() async {
if (FinampSettingsHelper.finampSettings.isOffline) {
if (_currentTrack != null) {
await _offlineListenLogHelper
.logOfflineListen(_currentTrack!.item.item);
}
return;
}
final playbackInfo = generateGenericPlaybackProgressInfo();
if (playbackInfo != null) {
try {
_resetPeriodicUpdates(); // delay next periodic update to avoid race conditions with old data
if (_lastReportedTrackStopped?.id != _currentTrack?.item.id) {
_lastReportedTrackStopped = _currentTrack?.item;
await _jellyfinApiHelper.stopPlaybackProgress(playbackInfo);
if (FinampSettingsHelper.finampSettings.isOffline) {
await _offlineListenLogHelper
.logOfflineListen(_currentTrack!.item.item);
} else {
await _jellyfinApiHelper.stopPlaybackProgress(playbackInfo);
}
}
} catch (e) {
_playbackHistoryServiceLogger.warning(e);
Expand Down

0 comments on commit 7791ee6

Please sign in to comment.