1
0
mirror of git://jb55.com/damus synced 2024-09-29 16:30:44 +00:00

Send device token when switching to push notifications mode

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
This commit is contained in:
Daniel D’Aquino 2024-05-20 14:35:03 -07:00
parent 8feb228ea0
commit a0f6bdd8d9
2 changed files with 12 additions and 3 deletions

View File

@ -79,7 +79,7 @@ enum Route: Hashable {
case .AppearanceSettings(let settings):
AppearanceSettingsView(damus_state: damusState, settings: settings)
case .NotificationSettings(let settings):
NotificationSettingsView(settings: settings)
NotificationSettingsView(damus_state: damusState, settings: settings)
case .ZapSettings(let settings):
ZapSettingsView(settings: settings)
case .TranslationSettings(let settings):

View File

@ -8,6 +8,7 @@
import SwiftUI
struct NotificationSettingsView: View {
let damus_state: DamusState
@ObservedObject var settings: UserSettingsStore
@Environment(\.dismiss) var dismiss
@ -28,7 +29,15 @@ struct NotificationSettingsView: View {
Form {
if settings.enable_experimental_push_notifications {
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($settings.notifications_mode)
selection: Binding(
get: { settings.notifications_mode },
set: { newValue in
settings.notifications_mode = newValue
if newValue == .push {
Task { try await damus_state.push_notification_client.send_token() }
}
}
)
) {
ForEach(UserSettingsStore.NotificationsMode.allCases, id: \.self) { notification_mode in
Text(notification_mode.text_description())
@ -76,6 +85,6 @@ struct NotificationSettingsView: View {
struct NotificationSettings_Previews: PreviewProvider {
static var previews: some View {
NotificationSettingsView(settings: UserSettingsStore())
NotificationSettingsView(damus_state: test_damus_state, settings: UserSettingsStore())
}
}