fix: notification settings initial state (#3763)

This commit is contained in:
Mathias Mogensen 2023-10-23 14:51:59 +02:00 committed by GitHub
parent b16a102f85
commit cd6e133c86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -18,6 +18,11 @@ class NotificationSettingsCubit extends Cubit<NotificationSettingsState> {
.getNotificationSettings()
.then((notificationSettings) {
_notificationSettings = notificationSettings;
emit(
state.copyWith(
isNotificationsEnabled: _notificationSettings.notificationsEnabled,
),
);
_initCompleter.complete();
});
}
@ -26,13 +31,14 @@ class NotificationSettingsCubit extends Cubit<NotificationSettingsState> {
await _initCompleter.future;
_notificationSettings.notificationsEnabled = !state.isNotificationsEnabled;
_saveNotificationSettings();
emit(
state.copyWith(
isNotificationsEnabled: _notificationSettings.notificationsEnabled,
),
);
_saveNotificationSettings();
}
Future<void> _saveNotificationSettings() async {

View File

@ -241,6 +241,7 @@ impl std::default::Default for DateTimeSettingsPB {
#[derive(ProtoBuf, Serialize, Deserialize, Debug, Clone)]
pub struct NotificationSettingsPB {
#[pb(index = 1)]
#[serde(default)]
pub notifications_enabled: bool,
}