Stop showing "Preview unavailable" while loading room preview details on the JoinRoomScreen

This commit is contained in:
Stefan Ceriu
2024-06-14 10:59:30 +03:00
committed by Stefan Ceriu
parent cefa38049f
commit 63a474bb3f
8 changed files with 63 additions and 39 deletions
@@ -74,6 +74,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
showLoadingIndicator()
defer {
updateMode()
hideLoadingIndicator()
}
@@ -85,6 +86,23 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
}
}
private func updateMode() {
guard let roomDetails = state.roomDetails else {
state.mode = .unknown
return
}
if roomDetails.isPublic {
state.mode = .join
} else if roomDetails.isInvited {
state.mode = .invited
} else if roomDetails.canKnock { // Knocking is not supported yet, treat it as .unknown
state.mode = .unknown
} else {
state.mode = .unknown
}
}
private func joinRoom() async {
showLoadingIndicator()