Crash: open private room by link. Use RoomId instead of the alias.
This commit is contained in:
parent
abe07c73a4
commit
e0556cd5e6
|
@ -0,0 +1,2 @@
|
||||||
|
Open a room by link: use the actual roomId instead of the alias
|
||||||
|
|
|
@ -24,7 +24,7 @@ sealed class MatrixToAction : VectorViewModelAction {
|
||||||
object FailedToResolveUser : MatrixToAction()
|
object FailedToResolveUser : MatrixToAction()
|
||||||
object FailedToStartChatting : MatrixToAction()
|
object FailedToStartChatting : MatrixToAction()
|
||||||
data class JoinSpace(val spaceID: String, val viaServers: List<String>?) : MatrixToAction()
|
data class JoinSpace(val spaceID: String, val viaServers: List<String>?) : MatrixToAction()
|
||||||
data class JoinRoom(val roomId: String, val viaServers: List<String>?) : MatrixToAction()
|
data class JoinRoom(val roomIdOrAlias: String, val viaServers: List<String>?) : MatrixToAction()
|
||||||
data class OpenSpace(val spaceID: String) : MatrixToAction()
|
data class OpenSpace(val spaceID: String) : MatrixToAction()
|
||||||
data class OpenRoom(val roomId: String) : MatrixToAction()
|
data class OpenRoom(val roomId: String) : MatrixToAction()
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import im.vector.app.core.resources.StringProvider
|
||||||
import im.vector.app.features.createdirect.DirectRoomHelper
|
import im.vector.app.features.createdirect.DirectRoomHelper
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import org.matrix.android.sdk.api.MatrixPatterns
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkData
|
import org.matrix.android.sdk.api.session.permalinks.PermalinkData
|
||||||
|
@ -296,8 +297,12 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
session.joinRoom(action.roomId, null, action.viaServers?.take(3) ?: emptyList())
|
session.joinRoom(
|
||||||
_viewEvents.post(MatrixToViewEvents.NavigateToRoom(action.roomId))
|
roomIdOrAlias = action.roomIdOrAlias,
|
||||||
|
reason = null,
|
||||||
|
viaServers = action.viaServers?.take(3) ?: emptyList()
|
||||||
|
)
|
||||||
|
_viewEvents.post(MatrixToViewEvents.NavigateToRoom(getRoomIdFromRoomIdOrAlias(action.roomIdOrAlias)))
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
_viewEvents.post(MatrixToViewEvents.ShowModalError(errorFormatter.toHumanReadable(failure)))
|
_viewEvents.post(MatrixToViewEvents.ShowModalError(errorFormatter.toHumanReadable(failure)))
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -309,6 +314,12 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun getRoomIdFromRoomIdOrAlias(roomIdOrAlias: String): String {
|
||||||
|
return if (MatrixPatterns.isRoomAlias(roomIdOrAlias)) {
|
||||||
|
session.getRoomIdByAlias(roomIdOrAlias, true).get().roomId
|
||||||
|
} else roomIdOrAlias
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleStartChatting(action: MatrixToAction.StartChattingWithUser) {
|
private fun handleStartChatting(action: MatrixToAction.StartChattingWithUser) {
|
||||||
setState {
|
setState {
|
||||||
copy(startChattingState = Loading())
|
copy(startChattingState = Loading())
|
||||||
|
|
Loading…
Reference in New Issue