Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash: open private room by link #5786

Merged
merged 6 commits into from
Apr 20, 2022
Merged

Conversation

Claire1817
Copy link
Contributor

@Claire1817 Claire1817 commented Apr 19, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Use roomId instead of alias for NavigateToRoom
In some cases, the alias was used instead of the room id. The alias was blocking the room creation in the DB.

Motivation and context

tchapgouv/tchap-android#554

Screenshots / GIFs

Tests

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@Claire1817 Claire1817 marked this pull request as draft April 19, 2022 12:00
@Claire1817 Claire1817 marked this pull request as ready for review April 19, 2022 12:12
@github-actions
Copy link

github-actions bot commented Apr 19, 2022

Unit Test Results

114 files  ±0  114 suites  ±0   1m 26s ⏱️ +12s
202 tests ±0  202 ✔️ ±0  0 💤 ±0  0 ±0 
678 runs  ±0  678 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit d2ab709. ± Comparison against base commit abe07c7.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@Florian14 Florian14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM. It could be nice to externalize the conversion of a roomAlias to a roomId or to support aliases for the navigation?

@Claire1817 Claire1817 requested review from a team and Florian14 and removed request for a team and Florian14 April 19, 2022 13:27
@Florian14 Florian14 requested review from a team and Florian14 and removed request for a team and Florian14 April 19, 2022 13:34
@ouchadam ouchadam requested review from a team and removed request for a team April 19, 2022 14:44
changelog.d/5786.bugfix Outdated Show resolved Hide resolved
@@ -296,8 +297,13 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
}
viewModelScope.launch {
try {
session.joinRoom(action.roomId, null, action.viaServers?.take(3) ?: emptyList())
_viewEvents.post(MatrixToViewEvents.NavigateToRoom(action.roomId))
session.joinRoom(action.roomIdOrAlias, null, action.viaServers?.take(3) ?: emptyList())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to help give extra context it would be handy if the null / true arguments used named parameters (or we could extract constants)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put the named parameters for all the arguments here :) it's more understandable.

session.joinRoom(action.roomId, null, action.viaServers?.take(3) ?: emptyList())
_viewEvents.post(MatrixToViewEvents.NavigateToRoom(action.roomId))
session.joinRoom(action.roomIdOrAlias, null, action.viaServers?.take(3) ?: emptyList())
val roomId: String = if (MatrixPatterns.isRoomAlias(action.roomIdOrAlias)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think it's worth extracting out a method for converting roomIdOrAlias to just roomId?

@@ -24,7 +24,7 @@ sealed class MatrixToAction : VectorViewModelAction {
object FailedToResolveUser : MatrixToAction()
object FailedToStartChatting : 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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking out loud for the future, I could imagine separate types for roomId, spaceId and roomAlias

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it could be separate. But i think this will generate a refacto.

Copy link
Contributor

@ouchadam ouchadam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some very minor comments, LGTM! 💯 will leave up to you to address if wanted

@@ -309,6 +314,12 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
}
}

private suspend fun getRoomIdFromRoomIdOrAlias(roomIdOrAlias: String): String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants