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

join and leave methods moved from MembershipService to RoomService an… #5183

Merged
merged 2 commits into from
Feb 10, 2022

Conversation

fedrunov
Copy link
Contributor

@fedrunov fedrunov commented Feb 8, 2022

There are methods to join and leave room/space in MembershipService but in context of this service (as part of Room) it's not always possible to validate if current instance is Room or Space and JoinRoomTask is always used, even though for spaces we should use JoinSpaceTask. This PR removes join and leave methods from MembershipService and replaces it with a separate implementation in RoomService and SpaceService according to context. This will allow us to properly track events for analytics and also will prevent possible bugs when Space is treated as Room

…d SpaceService to split logic for rooms and spaces
@github-actions
Copy link

github-actions bot commented Feb 8, 2022

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
    passed="25" failures="11" errors="0" skipped="2"
  • [org.matrix.android.sdk.account]
    passed="5" failures="0" errors="0" skipped="2"
  • [org.matrix.android.sdk.internal]
    passed="158" failures="8" errors="0" skipped="38"
  • [org.matrix.android.sdk.ordering]
    passed="1" failures="1" errors="0" skipped="0"
  • [org.matrix.android.sdk.PermalinkParserTest]
    passed="2" failures="0" errors="0" skipped="0"

@github-actions
Copy link

github-actions bot commented Feb 8, 2022

Unit Test Results

  76 files  ±0    76 suites  ±0   58s ⏱️ ±0s
144 tests ±0  144 ✔️ ±0  0 💤 ±0  0 ±0 
452 runs  ±0  452 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 2f4de46. ± Comparison against base commit 49a0555.

♻️ This comment has been updated with latest results.

Copy link
Member

@ganfra ganfra left a comment

Choose a reason for hiding this comment

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

Small remarks otherwise ok for me!

@@ -184,6 +184,10 @@ internal class DefaultSpaceService @Inject constructor(
return joinSpaceTask.execute(JoinSpaceTask.Params(spaceIdOrAlias, reason, viaServers))
}

override suspend fun leaveSpace(roomId: String, reason: String?) {
Copy link
Member

Choose a reason for hiding this comment

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

spaceId instead of roomId?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

initially changed to spaceId, but since we use Room for Space sometimes wasn't sure if it won't be confusing. Like
leaveSpace(spaceId = room.roomId). What do you think?

* @param roomId the roomId of the space to leave
* @param reason optional reason for leaving the space
*/
suspend fun leaveSpace(roomId: String, reason: String? = null)
Copy link
Member

Choose a reason for hiding this comment

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

spaceId instead of roomId?

@@ -225,7 +225,7 @@ class RoomListViewModel @AssistedInject constructor(
val room = session.getRoom(roomId) ?: return@withState
Copy link
Member

Choose a reason for hiding this comment

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

remove this line?

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.

also looks good to me! just missing a changelog entry, as it's touching the sdk api I guess we'll need to use .sdk for the file type

Will leave to @ganfra to merge 💪

@fedrunov fedrunov requested a review from ganfra February 9, 2022 13:23
Copy link
Member

@ganfra ganfra left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

@fedrunov fedrunov merged commit 06b5563 into develop Feb 10, 2022
@fedrunov fedrunov deleted the feature/nfe/separate_join_methods branch February 10, 2022 09:05
@@ -72,14 +72,14 @@ class SpaceLeaveAdvancedViewModel @AssistedInject constructor(
try {
state.selectedRooms.forEach {
try {
session.getRoom(it)?.leave(null)
session.leaveRoom(it)
Copy link
Member

Choose a reason for hiding this comment

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

Behind the scene I think this is equivalent to leave a room or a space, but can it be a spaceId sometimes here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far i understand we leave all selected rooms in a space here. Maybe there could be also subspaces, but I think rooms is more often and more relevant here.

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