diff --git a/ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift b/ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift index 6f87acb..53d2bf2 100644 --- a/ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift +++ b/ServiceLayer/Sources/ServiceLayer/Services/IdentityService.swift @@ -190,10 +190,10 @@ public extension IdentityService { contentDatabase.pickerEmojisPublisher() } - func updatePreferences(_ preferences: Identity.Preferences) -> AnyPublisher { + func updatePreferences(_ preferences: Identity.Preferences, authenticated: Bool) -> AnyPublisher { identityDatabase.updatePreferences(preferences, id: id) .collect() - .filter { _ in preferences.useServerPostingReadingPreferences } + .filter { _ in preferences.useServerPostingReadingPreferences && authenticated } .flatMap { _ in refreshServerPreferences() } .eraseToAnyPublisher() } diff --git a/ViewModels/Sources/ViewModels/View Models/PreferencesViewModel.swift b/ViewModels/Sources/ViewModels/View Models/PreferencesViewModel.swift index d9c1230..2dfea0c 100644 --- a/ViewModels/Sources/ViewModels/View Models/PreferencesViewModel.swift +++ b/ViewModels/Sources/ViewModels/View Models/PreferencesViewModel.swift @@ -26,7 +26,11 @@ public final class PreferencesViewModel: ObservableObject { $preferences .dropFirst() - .flatMap(identityContext.service.updatePreferences) + .flatMap { + identityContext.service.updatePreferences( + $0, + authenticated: identityContext.identity.authenticated) + } .assignErrorsToAlertItem(to: \.alertItem, on: self) .sink { _ in } .store(in: &cancellables) diff --git a/Views/SwiftUI/PreferencesView.swift b/Views/SwiftUI/PreferencesView.swift index ded7a54..4b3f122 100644 --- a/Views/SwiftUI/PreferencesView.swift +++ b/Views/SwiftUI/PreferencesView.swift @@ -59,7 +59,8 @@ struct PreferencesView: View { Toggle("preferences.reading-expand-spoilers", isOn: $viewModel.preferences.readingExpandSpoilers) } - .disabled(viewModel.preferences.useServerPostingReadingPreferences) + .disabled(viewModel.preferences.useServerPostingReadingPreferences + && viewModel.identityContext.identity.authenticated) } Section(header: Text("preferences.app")) { Picker("preferences.status-word", @@ -100,16 +101,19 @@ struct PreferencesView: View { .disabled(reduceMotion) Toggle("preferences.show-reblog-and-favorite-counts", isOn: $identityContext.appPreferences.showReblogAndFavoriteCounts) - Picker("preferences.home-timeline-position-on-startup", - selection: $identityContext.appPreferences.homeTimelineBehavior) { - ForEach(AppPreferences.PositionBehavior.allCases) { option in - Text(option.localizedStringKey).tag(option) + if viewModel.identityContext.identity.authenticated + && !viewModel.identityContext.identity.pending { + Picker("preferences.home-timeline-position-on-startup", + selection: $identityContext.appPreferences.homeTimelineBehavior) { + ForEach(AppPreferences.PositionBehavior.allCases) { option in + Text(option.localizedStringKey).tag(option) + } } - } - Picker("preferences.notifications-position-on-startup", - selection: $identityContext.appPreferences.notificationsTabBehavior) { - ForEach(AppPreferences.PositionBehavior.allCases) { option in - Text(option.localizedStringKey).tag(option) + Picker("preferences.notifications-position-on-startup", + selection: $identityContext.appPreferences.notificationsTabBehavior) { + ForEach(AppPreferences.PositionBehavior.allCases) { option in + Text(option.localizedStringKey).tag(option) + } } } }