diff --git a/damus/Models/NotificationsManager.swift b/damus/Models/NotificationsManager.swift index 2ae900fe..adbd0776 100644 --- a/damus/Models/NotificationsManager.swift +++ b/damus/Models/NotificationsManager.swift @@ -27,7 +27,7 @@ func process_local_notification(state: HeadlessDamusState, event ev: NostrEvent) func should_display_notification(state: HeadlessDamusState, event ev: NostrEvent, mode: UserSettingsStore.NotificationsMode) -> Bool { // Do not show notification if it's coming from a mode different from the one selected by our user - guard state.settings.notifications_mode == mode else { + guard state.settings.notification_mode == mode else { return false } diff --git a/damus/Models/PushNotificationClient.swift b/damus/Models/PushNotificationClient.swift index dc385e2c..f92d8367 100644 --- a/damus/Models/PushNotificationClient.swift +++ b/damus/Models/PushNotificationClient.swift @@ -18,7 +18,7 @@ struct PushNotificationClient { mutating func set_device_token(new_device_token: Data) async throws { self.device_token = new_device_token - if settings.enable_experimental_push_notifications && settings.notifications_mode == .push { + if settings.enable_push_notifications && settings.notification_mode == .push { try await self.send_token() } } diff --git a/damus/Models/UserSettingsStore.swift b/damus/Models/UserSettingsStore.swift index 16b221ff..ff884aa1 100644 --- a/damus/Models/UserSettingsStore.swift +++ b/damus/Models/UserSettingsStore.swift @@ -155,8 +155,8 @@ class UserSettingsStore: ObservableObject { @Setting(key: "like_notification", default_value: true) var like_notification: Bool - @StringSetting(key: "notifications_mode", default_value: .local) - var notifications_mode: NotificationsMode + @StringSetting(key: "notification_mode", default_value: .push) + var notification_mode: NotificationsMode @Setting(key: "notification_only_from_following", default_value: false) var notification_only_from_following: Bool @@ -207,8 +207,9 @@ class UserSettingsStore: ObservableObject { @Setting(key: "always_show_onboarding_suggestions", default_value: false) var always_show_onboarding_suggestions: Bool - @Setting(key: "enable_experimental_push_notifications", default_value: false) - var enable_experimental_push_notifications: Bool + // @Setting(key: "enable_experimental_push_notifications", default_value: false) + // This was a feature flag setting during early development, but now this is enabled for everyone. + var enable_push_notifications: Bool = true @StringSetting(key: "push_notification_environment", default_value: .production) var push_notification_environment: PushNotificationClient.Environment diff --git a/damus/Views/Settings/DeveloperSettingsView.swift b/damus/Views/Settings/DeveloperSettingsView.swift index cd60b230..c3fdd982 100644 --- a/damus/Views/Settings/DeveloperSettingsView.swift +++ b/damus/Views/Settings/DeveloperSettingsView.swift @@ -18,10 +18,6 @@ struct DeveloperSettingsView: View { .toggleStyle(.switch) if settings.developer_mode { Toggle(NSLocalizedString("Always show onboarding", comment: "Developer mode setting to always show onboarding suggestions."), isOn: $settings.always_show_onboarding_suggestions) - - Toggle(NSLocalizedString("Enable experimental push notifications", comment: "Developer mode setting to enable experimental push notifications."), isOn: $settings.enable_experimental_push_notifications) - .toggleStyle(.switch) - Picker(NSLocalizedString("Push notification environment", comment: "Prompt selection of the Push notification environment (Developer feature to switch between real/production mode to test modes)."), selection: Binding( get: { () -> PushNotificationClient.Environment in diff --git a/damus/Views/Settings/NotificationSettingsView.swift b/damus/Views/Settings/NotificationSettingsView.swift index 4ce30ef4..e5185242 100644 --- a/damus/Views/Settings/NotificationSettingsView.swift +++ b/damus/Views/Settings/NotificationSettingsView.swift @@ -36,7 +36,7 @@ struct NotificationSettingsView: View { do { try await damus_state.push_notification_client.send_token() await self.sync_up_remote_notification_settings() - settings.notifications_mode = new_value + settings.notification_mode = new_value } catch { notification_mode_setting_error = String(format: NSLocalizedString("Error configuring push notifications with the server: %@", comment: "Error label shown when user tries to enable push notifications but something fails"), error.localizedDescription) @@ -47,7 +47,7 @@ struct NotificationSettingsView: View { Task { do { try await damus_state.push_notification_client.revoke_token() - settings.notifications_mode = new_value + settings.notification_mode = new_value notification_preferences_sync_state = .not_applicable } catch { @@ -67,7 +67,7 @@ struct NotificationSettingsView: View { set: { new_value in let old_value = raw_binding.wrappedValue raw_binding.wrappedValue = new_value - if self.settings.notifications_mode == .push { + if self.settings.notification_mode == .push { Task { await self.send_push_notification_preferences(on_failure: { raw_binding.wrappedValue = old_value @@ -114,7 +114,7 @@ struct NotificationSettingsView: View { var body: some View { Form { - if settings.enable_experimental_push_notifications { + if settings.enable_push_notifications { Section( header: Text("General", comment: "Section header for general damus notifications user configuration"), footer: VStack { @@ -126,7 +126,7 @@ struct NotificationSettingsView: View { ) { Picker(NSLocalizedString("Notifications mode", comment: "Prompt selection of the notification mode (Feature to switch between local notifications (generated from user's own phone) or push notifications (generated by Damus server)."), selection: Binding( - get: { settings.notifications_mode }, + get: { settings.notification_mode }, set: { newValue in self.try_to_set_notifications_mode(new_value: newValue) } @@ -194,7 +194,7 @@ struct NotificationSettingsView: View { } .onAppear(perform: { Task { - if self.settings.notifications_mode == .push { + if self.settings.notification_mode == .push { await self.sync_up_remote_notification_settings() } }