mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 08:10:59 +00:00
Fix preferences when browsing
This commit is contained in:
parent
e50b2bddad
commit
cdec2e0082
3 changed files with 21 additions and 13 deletions
|
@ -190,10 +190,10 @@ public extension IdentityService {
|
||||||
contentDatabase.pickerEmojisPublisher()
|
contentDatabase.pickerEmojisPublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
func updatePreferences(_ preferences: Identity.Preferences) -> AnyPublisher<Never, Error> {
|
func updatePreferences(_ preferences: Identity.Preferences, authenticated: Bool) -> AnyPublisher<Never, Error> {
|
||||||
identityDatabase.updatePreferences(preferences, id: id)
|
identityDatabase.updatePreferences(preferences, id: id)
|
||||||
.collect()
|
.collect()
|
||||||
.filter { _ in preferences.useServerPostingReadingPreferences }
|
.filter { _ in preferences.useServerPostingReadingPreferences && authenticated }
|
||||||
.flatMap { _ in refreshServerPreferences() }
|
.flatMap { _ in refreshServerPreferences() }
|
||||||
.eraseToAnyPublisher()
|
.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,11 @@ public final class PreferencesViewModel: ObservableObject {
|
||||||
|
|
||||||
$preferences
|
$preferences
|
||||||
.dropFirst()
|
.dropFirst()
|
||||||
.flatMap(identityContext.service.updatePreferences)
|
.flatMap {
|
||||||
|
identityContext.service.updatePreferences(
|
||||||
|
$0,
|
||||||
|
authenticated: identityContext.identity.authenticated)
|
||||||
|
}
|
||||||
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
||||||
.sink { _ in }
|
.sink { _ in }
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
|
@ -59,7 +59,8 @@ struct PreferencesView: View {
|
||||||
Toggle("preferences.reading-expand-spoilers",
|
Toggle("preferences.reading-expand-spoilers",
|
||||||
isOn: $viewModel.preferences.readingExpandSpoilers)
|
isOn: $viewModel.preferences.readingExpandSpoilers)
|
||||||
}
|
}
|
||||||
.disabled(viewModel.preferences.useServerPostingReadingPreferences)
|
.disabled(viewModel.preferences.useServerPostingReadingPreferences
|
||||||
|
&& viewModel.identityContext.identity.authenticated)
|
||||||
}
|
}
|
||||||
Section(header: Text("preferences.app")) {
|
Section(header: Text("preferences.app")) {
|
||||||
Picker("preferences.status-word",
|
Picker("preferences.status-word",
|
||||||
|
@ -100,16 +101,19 @@ struct PreferencesView: View {
|
||||||
.disabled(reduceMotion)
|
.disabled(reduceMotion)
|
||||||
Toggle("preferences.show-reblog-and-favorite-counts",
|
Toggle("preferences.show-reblog-and-favorite-counts",
|
||||||
isOn: $identityContext.appPreferences.showReblogAndFavoriteCounts)
|
isOn: $identityContext.appPreferences.showReblogAndFavoriteCounts)
|
||||||
Picker("preferences.home-timeline-position-on-startup",
|
if viewModel.identityContext.identity.authenticated
|
||||||
selection: $identityContext.appPreferences.homeTimelineBehavior) {
|
&& !viewModel.identityContext.identity.pending {
|
||||||
ForEach(AppPreferences.PositionBehavior.allCases) { option in
|
Picker("preferences.home-timeline-position-on-startup",
|
||||||
Text(option.localizedStringKey).tag(option)
|
selection: $identityContext.appPreferences.homeTimelineBehavior) {
|
||||||
|
ForEach(AppPreferences.PositionBehavior.allCases) { option in
|
||||||
|
Text(option.localizedStringKey).tag(option)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
Picker("preferences.notifications-position-on-startup",
|
||||||
Picker("preferences.notifications-position-on-startup",
|
selection: $identityContext.appPreferences.notificationsTabBehavior) {
|
||||||
selection: $identityContext.appPreferences.notificationsTabBehavior) {
|
ForEach(AppPreferences.PositionBehavior.allCases) { option in
|
||||||
ForEach(AppPreferences.PositionBehavior.allCases) { option in
|
Text(option.localizedStringKey).tag(option)
|
||||||
Text(option.localizedStringKey).tag(option)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue