Hide notification type prefs unless registered

This commit is contained in:
Justin Mazzocchi 2020-08-16 13:30:28 -07:00
parent c64fa26b09
commit f6568abad9
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
2 changed files with 8 additions and 3 deletions

View File

@ -4,12 +4,15 @@ import Foundation
class PreferencesViewModel: ObservableObject { class PreferencesViewModel: ObservableObject {
let handle: String let handle: String
let shouldShowNotificationTypePreferences: Bool
private let identityService: IdentityService private let identityService: IdentityService
init(identityService: IdentityService) { init(identityService: IdentityService) {
self.identityService = identityService self.identityService = identityService
handle = identityService.identity.handle handle = identityService.identity.handle
shouldShowNotificationTypePreferences = identityService.identity.lastRegisteredDeviceToken != nil
} }
} }

View File

@ -11,9 +11,11 @@ struct PreferencesView: View {
NavigationLink("preferences.posting-reading", NavigationLink("preferences.posting-reading",
destination: PostingReadingPreferencesView( destination: PostingReadingPreferencesView(
viewModel: viewModel.postingReadingPreferencesViewModel())) viewModel: viewModel.postingReadingPreferencesViewModel()))
NavigationLink("preferences.notification-types", if viewModel.shouldShowNotificationTypePreferences {
destination: NotificationTypesPreferencesView( NavigationLink("preferences.notification-types",
viewModel: viewModel.notificationTypesPreferencesViewModel())) destination: NotificationTypesPreferencesView(
viewModel: viewModel.notificationTypesPreferencesViewModel()))
}
} }
} }
.navigationTitle("preferences") .navigationTitle("preferences")