mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Automatically dismiss UserDetailsEditScreen when saving changes. (#5073)
This commit is contained in:
+3
-5
@@ -112,11 +112,11 @@ class UserDetailsEditScreenViewModel: UserDetailsEditScreenViewModelType, UserDe
|
|||||||
state.bindings.alertInfo = .init(id: .unsavedChanges,
|
state.bindings.alertInfo = .init(id: .unsavedChanges,
|
||||||
title: L10n.dialogUnsavedChangesTitle,
|
title: L10n.dialogUnsavedChangesTitle,
|
||||||
message: L10n.dialogUnsavedChangesDescription,
|
message: L10n.dialogUnsavedChangesDescription,
|
||||||
primaryButton: .init(title: L10n.actionSave) { Task { await self.saveUserDetails(shouldDismiss: true) } },
|
primaryButton: .init(title: L10n.actionSave) { Task { await self.saveUserDetails() } },
|
||||||
secondaryButton: .init(title: L10n.actionDiscard, role: .cancel) { self.actionsSubject.send(.dismiss) })
|
secondaryButton: .init(title: L10n.actionDiscard, role: .cancel) { self.actionsSubject.send(.dismiss) })
|
||||||
}
|
}
|
||||||
|
|
||||||
private func saveUserDetails(shouldDismiss: Bool = false) async {
|
private func saveUserDetails() async {
|
||||||
let userIndicatorID = UUID().uuidString
|
let userIndicatorID = UUID().uuidString
|
||||||
defer {
|
defer {
|
||||||
userIndicatorController.retractIndicatorWithId(userIndicatorID)
|
userIndicatorController.retractIndicatorWithId(userIndicatorID)
|
||||||
@@ -147,9 +147,7 @@ class UserDetailsEditScreenViewModel: UserDetailsEditScreenViewModelType, UserDe
|
|||||||
try await group.waitForAll()
|
try await group.waitForAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
if shouldDismiss {
|
actionsSubject.send(.dismiss)
|
||||||
actionsSubject.send(.dismiss)
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
userIndicatorController.alertInfo = .init(id: .init(),
|
userIndicatorController.alertInfo = .init(id: .init(),
|
||||||
title: L10n.screenEditProfileErrorTitle,
|
title: L10n.screenEditProfileErrorTitle,
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ class UserDetailsEditScreenViewModelTests: XCTestCase {
|
|||||||
func testSave() async throws {
|
func testSave() async throws {
|
||||||
setupViewModel()
|
setupViewModel()
|
||||||
|
|
||||||
// Saving shouldn't dismiss this screen (or trigger any other action).
|
let deferred = deferFulfillment(viewModel.actions) { $0 == .dismiss }
|
||||||
let deferred = deferFailure(viewModel.actions, timeout: 1) { _ in true }
|
|
||||||
|
|
||||||
context.name = "name"
|
context.name = "name"
|
||||||
context.send(viewAction: .save)
|
context.send(viewAction: .save)
|
||||||
|
|||||||
Reference in New Issue
Block a user