Add error handling for push sync

This commit is contained in:
Alfonso Grillo
2023-01-31 12:24:55 +01:00
parent 1d94c4776d
commit 2b70ef843e
5 changed files with 47 additions and 6 deletions
@@ -21,6 +21,7 @@ import SwiftUI
/// Also renders an optional bottom section.
/// Used in the case of keywords, for the keyword chips and input.
struct NotificationSettings<BottomSection: View>: View {
@Environment(\.theme) var theme: ThemeSwiftUI
@ObservedObject var viewModel: NotificationSettingsViewModel
var bottomSection: BottomSection?
@@ -31,10 +32,18 @@ struct NotificationSettings<BottomSection: View>: View {
header: FormSectionHeader(text: VectorL10n.settingsNotifyMeFor)
) {
ForEach(viewModel.viewState.ruleIds) { ruleId in
let checked = viewModel.viewState.selectionState[ruleId] ?? false
FormPickerItem(title: ruleId.title, selected: checked) {
Task {
await viewModel.update(ruleID: ruleId, isChecked: !checked)
VStack(alignment: .leading, spacing: 4) {
let checked = viewModel.viewState.selectionState[ruleId] ?? false
FormPickerItem(title: ruleId.title, selected: checked) {
viewModel.update(ruleID: ruleId, isChecked: !checked)
}
if viewModel.isRuleOutOfSync(ruleId) {
Text(VectorL10n.settingsPushRulesError)
.font(theme.fonts.caption1)
.foregroundColor(theme.colors.alert)
.padding(.horizontal)
.padding(.bottom, 16)
}
}
}