Bottom Sheet to confirm DM creation (#3739)

* created the view to hold the bottom sheet

* added the sheet to the start chat screen

* switched the alert with the bottom sheet

in the room member details

* add a small delay to not always show the loader

* suggested PR changes

* pr suggestions and updated tests
This commit is contained in:
Mauro
2025-02-05 13:28:00 +01:00
committed by GitHub
parent 42257a18db
commit 921d1c627d
21 changed files with 216 additions and 54 deletions
@@ -54,20 +54,23 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
case .createRoom:
actionsSubject.send(.createRoom)
case .selectUser(let user):
showLoadingIndicator()
showLoadingIndicator(delay: .milliseconds(200))
Task {
let currentDirectRoom = await userSession.clientProxy.directRoomForUserID(user.userID)
switch currentDirectRoom {
case .success(.some(let roomId)):
self.hideLoadingIndicator()
self.actionsSubject.send(.openRoom(withIdentifier: roomId))
hideLoadingIndicator()
actionsSubject.send(.openRoom(withIdentifier: roomId))
case .success:
await self.createDirectRoom(with: user)
hideLoadingIndicator()
state.bindings.selectedUserToInvite = user
case .failure:
self.hideLoadingIndicator()
self.displayError()
hideLoadingIndicator()
displayError()
}
}
case .createDM(let user):
Task { await createDirectRoom(user: user) }
}
}
@@ -107,7 +110,7 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
}
}
private func createDirectRoom(with user: UserProfileProxy) async {
private func createDirectRoom(user: UserProfileProxy) async {
defer {
hideLoadingIndicator()
}
@@ -131,11 +134,12 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie
private static let loadingIndicatorIdentifier = "\(StartChatScreenViewModel.self)-Loading"
private func showLoadingIndicator() {
private func showLoadingIndicator(delay: Duration? = nil) {
userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
type: .modal(progress: .indeterminate, interactiveDismissDisabled: true, allowsInteraction: false),
title: L10n.commonLoading,
persistent: true))
persistent: true),
delay: delay)
}
private func hideLoadingIndicator() {