adds retry functionality

This commit is contained in:
2025-09-05 15:13:55 +02:00
parent 99711d56ec
commit 7828e48d9d
7 changed files with 414 additions and 47 deletions

View File

@@ -23,6 +23,11 @@ class SettingsProvider extends ChangeNotifier {
// Notifications
int _snoozeMinutes = 10;
// Notification retry settings
bool _notificationRetryEnabled = true;
int _notificationRetryCount = 3;
int _notificationRetryDelayMinutes = 5;
// Auto-sync settings
bool _autoSyncEnabled = false;
int _autoSyncDebounceSeconds = 5;
@@ -42,6 +47,11 @@ class SettingsProvider extends ChangeNotifier {
// Notifications
int get snoozeMinutes => _snoozeMinutes;
// Notification retry getters
bool get notificationRetryEnabled => _notificationRetryEnabled;
int get notificationRetryCount => _notificationRetryCount;
int get notificationRetryDelayMinutes => _notificationRetryDelayMinutes;
// Auto-sync getters
bool get autoSyncEnabled => _autoSyncEnabled;
int get autoSyncDebounceSeconds => _autoSyncDebounceSeconds;
@@ -85,6 +95,11 @@ class SettingsProvider extends ChangeNotifier {
// Load snooze setting
_snoozeMinutes = prefs.getInt('snooze_minutes') ?? 10;
// Load notification retry settings
_notificationRetryEnabled = prefs.getBool('notification_retry_enabled') ?? true;
_notificationRetryCount = prefs.getInt('notification_retry_count') ?? 3;
_notificationRetryDelayMinutes = prefs.getInt('notification_retry_delay_minutes') ?? 5;
// Load auto-sync settings
_autoSyncEnabled = prefs.getBool('auto_sync_enabled') ?? false;
_autoSyncDebounceSeconds = prefs.getInt('auto_sync_debounce_seconds') ?? 30;
@@ -259,6 +274,37 @@ class SettingsProvider extends ChangeNotifier {
await prefs.setInt('snooze_minutes', minutes);
}
Future<void> setNotificationRetryEnabled(bool enabled) async {
_notificationRetryEnabled = enabled;
notifyListeners();
final prefs = await SharedPreferences.getInstance();
await prefs.setBool('notification_retry_enabled', enabled);
}
Future<void> setNotificationRetryCount(int count) async {
if (count < 0 || count > 10) {
throw ArgumentError('Retry count must be between 0 and 10');
}
_notificationRetryCount = count;
notifyListeners();
final prefs = await SharedPreferences.getInstance();
await prefs.setInt('notification_retry_count', count);
}
Future<void> setNotificationRetryDelayMinutes(int minutes) async {
const allowed = [1, 2, 3, 5, 10, 15, 20, 30];
if (!allowed.contains(minutes)) {
throw ArgumentError('Retry delay must be one of ${allowed.join(", ")} minutes');
}
_notificationRetryDelayMinutes = minutes;
notifyListeners();
final prefs = await SharedPreferences.getInstance();
await prefs.setInt('notification_retry_delay_minutes', minutes);
}
// Auto-sync setters
Future<void> setAutoSyncEnabled(bool enabled) async {
_autoSyncEnabled = enabled;