feat: Enhance APNS token retrieval with retries and add cancel functionality to revert changes in notification and privacy settings.
This commit is contained in:
@@ -22,6 +22,10 @@ class _NotificationsTabState extends ConsumerState<NotificationsTab> {
|
||||
bool _isLoadingNotifications = false;
|
||||
bool _isSavingNotifications = false;
|
||||
|
||||
// Snapshot of original values for cancel/reset
|
||||
Map<String, Map<String, bool>> _originalPrefs = {};
|
||||
String _originalFrequency = 'instant';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -55,6 +59,12 @@ class _NotificationsTabState extends ConsumerState<NotificationsTab> {
|
||||
_digestFrequency = data['digestFrequency'] as String? ?? 'instant';
|
||||
_isLoadingNotifications = false;
|
||||
_notificationsLoaded = true;
|
||||
// Save snapshot for cancel/reset
|
||||
_originalPrefs = {
|
||||
for (final e in _notificationPrefs.entries)
|
||||
e.key: Map<String, bool>.from(e.value),
|
||||
};
|
||||
_originalFrequency = _digestFrequency;
|
||||
});
|
||||
} catch (_) {
|
||||
setState(() {
|
||||
@@ -144,8 +154,12 @@ class _NotificationsTabState extends ConsumerState<NotificationsTab> {
|
||||
ProfileActionButtons(
|
||||
onSave: _saveNotificationSettings,
|
||||
onCancel: () {
|
||||
_notificationsLoaded = false;
|
||||
_loadNotificationPreferences();
|
||||
setState(() {
|
||||
for (final key in _originalPrefs.keys) {
|
||||
_notificationPrefs[key] = Map<String, bool>.from(_originalPrefs[key]!);
|
||||
}
|
||||
_digestFrequency = _originalFrequency;
|
||||
});
|
||||
},
|
||||
isSaving: _isSavingNotifications,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user