import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:shared_preferences/shared_preferences.dart'; part 'sync_progress_provider.g.dart'; /// Key for storing the sync-progress-for-cached-pages preference. const String _syncProgressKey = 'sync_progress_for_cached_pages'; /// Provider for the "Sync progress for cached pages" setting. /// /// When enabled, the app fires a GET request for each page turn so the OPDS /// server (e.g. Kavita) can track reading progress even when images are served /// from the local cache. This uses additional data. @riverpod class SyncProgressNotifier extends _$SyncProgressNotifier { @override bool build() { _load(); return false; // Default: off (saves data) } Future _load() async { final prefs = await SharedPreferences.getInstance(); final stored = prefs.getBool(_syncProgressKey); if (stored != null) { state = stored; } } Future setSyncProgress(bool enabled) async { state = enabled; final prefs = await SharedPreferences.getInstance(); await prefs.setBool(_syncProgressKey, enabled); } }