mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user