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:
@@ -79,7 +79,7 @@ enum Route: Hashable {
|
|||||||
case .AppearanceSettings(let settings):
|
case .AppearanceSettings(let settings):
|
||||||
AppearanceSettingsView(damus_state: damusState, settings: settings)
|
AppearanceSettingsView(damus_state: damusState, settings: settings)
|
||||||
case .NotificationSettings(let settings):
|
case .NotificationSettings(let settings):
|
||||||
NotificationSettingsView(settings: settings)
|
NotificationSettingsView(damus_state: damusState, settings: settings)
|
||||||
case .ZapSettings(let settings):
|
case .ZapSettings(let settings):
|
||||||
ZapSettingsView(settings: settings)
|
ZapSettingsView(settings: settings)
|
||||||
case .TranslationSettings(let settings):
|
case .TranslationSettings(let settings):
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct NotificationSettingsView: View {
|
struct NotificationSettingsView: View {
|
||||||
|
let damus_state: DamusState
|
||||||
@ObservedObject var settings: UserSettingsStore
|
@ObservedObject var settings: UserSettingsStore
|
||||||
|
|
||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
@@ -28,7 +29,15 @@ struct NotificationSettingsView: View {
|
|||||||
Form {
|
Form {
|
||||||
if settings.enable_experimental_push_notifications {
|
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)."),
|
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
|
ForEach(UserSettingsStore.NotificationsMode.allCases, id: \.self) { notification_mode in
|
||||||
Text(notification_mode.text_description())
|
Text(notification_mode.text_description())
|
||||||
@@ -76,6 +85,6 @@ struct NotificationSettingsView: View {
|
|||||||
|
|
||||||
struct NotificationSettings_Previews: PreviewProvider {
|
struct NotificationSettings_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
NotificationSettingsView(settings: UserSettingsStore())
|
NotificationSettingsView(damus_state: test_damus_state, settings: UserSettingsStore())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user