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

View File

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