Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix offline listening time inflating 10-20x when server unreachable

Barnabas42f6c93e3ad3
diff --git a/lib/services/audio_player_service.dart b/lib/services/audio_player_service.dart
index 286bb1e6..6d1a39fb 100644
--- a/lib/services/audio_player_service.dart
+++ b/lib/services/audio_player_service.dart
@@ -2500,6 +2500,11 @@ class AudioPlayerService extends ChangeNotifier {
? '$_currentItemId-$_currentEpisodeId'
: _currentItemId!;
_progressSync.addOfflineListeningTime(progressKey, sinceLastSync.clamp(0, 300));
+ // Reset the sync clock so the next tick waits a full interval
+ // before accumulating again. Without this, every subsequent tick
+ // (every 3-5s of position time) passes the threshold and tacks
+ // on another 300s, inflating offline listening by 10-20x.
+ _lastServerSync = DateTime.now();
}
if (manualOffline) {