Skip to content

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Sep 15, 2025

Content

Add UI for the ability to leave space.

Waiting for new Rust SDK api to get the list of rooms to left when leaving the space to finalize the work, but this PR can be reviewed and merged, the entry point to leave the space has been commented out.

Sharing a space should work though.

Motivation and context

Closes #5300
Partially implement #5301

Screenshots / GIFs

See recorded ones

Tests

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@bmarty bmarty requested a review from a team as a code owner September 15, 2025 14:25
@bmarty bmarty added the PR-Wip For anything that isn't ready to ship and will be enabled at a later date label Sep 15, 2025
@bmarty bmarty requested review from jmartinesp and removed request for a team September 15, 2025 14:25
Copy link
Contributor

github-actions bot commented Sep 15, 2025

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/1nSXY2

Copy link

codecov bot commented Sep 15, 2025

Codecov Report

❌ Patch coverage is 85.47945% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.97%. Comparing base (1e54633) to head (ef36922).
⚠️ Report is 15 commits behind head on develop.

Files with missing lines Patch % Lines
...d/features/space/impl/leave/LeaveSpacePresenter.kt 46.51% 23 Missing ⚠️
...ndroid/features/space/impl/leave/LeaveSpaceView.kt 92.63% 7 Missing and 7 partials ⚠️
...o/element/android/appnav/LoggedInEventProcessor.kt 0.00% 6 Missing ⚠️
...roid/features/space/impl/leave/LeaveSpaceEvents.kt 0.00% 5 Missing ⚠️
...ment/android/features/space/impl/root/SpaceView.kt 80.00% 4 Missing ⚠️
...atures/space/impl/leave/LeaveSpaceStateProvider.kt 98.59% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5354      +/-   ##
===========================================
- Coverage    80.99%   80.97%   -0.02%     
===========================================
  Files         2306     2312       +6     
  Lines        63090    63448     +358     
  Branches      7977     8010      +33     
===========================================
+ Hits         51099    51378     +279     
- Misses        9060     9131      +71     
- Partials      2931     2939       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM in general, a couple of comments but nothing blocking.

Comment on lines 12 to 13
data object StartLeaveSpace : SpaceEvents
data object LeaveSpace : SpaceEvents
Copy link
Member

Choose a reason for hiding this comment

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

Do we have some naming/structure we usually follow for these cases?

I think we'd usually have something like data class LeaveSpace(val needsConfirmation: Boolean) and use tell apart the 2 states. Or we'd also sometimes have LeaveSpace and some DoLeaveSpace events, if I'm not mistaken.

Copy link
Member Author

Choose a reason for hiding this comment

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

True, we also have AsyncAction with a confirmation state, which is maybe better here. I'll give it a try

Copy link
Member Author

Choose a reason for hiding this comment

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

class RoomMembershipObserver {
data class RoomMembershipUpdate(
val roomId: RoomId,
val roomInfo: RoomInfo,
Copy link
Member

Choose a reason for hiding this comment

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

It seems a bit weird to bundle the whole RoomInfo here, is it just to have access to the isSpace property?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Nit: the phrasing here seems a bit odd, I'd expect something like "You'll be leaving all your rooms in this space too", which seems simpler. But if it was designed like this 🤷 .

Copy link
Member Author

@bmarty bmarty Sep 15, 2025

Choose a reason for hiding this comment

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

The wording will probably get updated, I'll move this PR to draft.

@bmarty bmarty marked this pull request as draft September 15, 2025 15:53
@bmarty bmarty force-pushed the feature/bma/leaveSpace branch 2 times, most recently from 7406259 to a916661 Compare September 25, 2025 20:51
@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 25, 2025
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 25, 2025
@ElementBot
Copy link
Collaborator

ElementBot commented Sep 25, 2025

Warnings
⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L7 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L36 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L234 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L239 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L268 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L284 - For locale "cs" (Czech) the following quantities should also be defined: few (e.g. "2 dny"), many (e.g. "10.0 dne"), one (e.g. "1 den")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L295 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L323 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L430 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

Generated by 🚫 dangerJS against ef36922

@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 26, 2025
@bmarty bmarty changed the title Leave space Leave space - UI Sep 26, 2025
@bmarty bmarty force-pushed the feature/bma/leaveSpace branch from 5f88777 to 4d1a503 Compare September 26, 2025 12:19
@bmarty bmarty added Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. and removed Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. labels Sep 26, 2025
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 26, 2025
@bmarty
Copy link
Member Author

bmarty commented Sep 26, 2025

@jmartinesp the UI has changed a bit, and we may want to merge this PR even if the usage of the SDK is not finished. The entry point to leave Space has been commented out. This would need a brand new review I think. Sorry for the extra work!

@bmarty bmarty requested a review from jmartinesp September 26, 2025 12:58
@bmarty bmarty marked this pull request as ready for review September 26, 2025 13:46
@bmarty bmarty added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 26, 2025
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 26, 2025
Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

A few comments, I also haven't really tested the latest changes.

mutableStateOf<Set<RoomId>>(emptySet())
}
val joinedSpaceRooms by produceState(emptyList()) {
// TODO Get the joined room from the SDK, should also have the
Copy link
Member

Choose a reason for hiding this comment

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

This comment seems incomplete, so much suspense 🕵️ .

@Composable
private fun LeaveSpaceButtons(
showLeaveButton: Boolean,
nbOfSelectedRooms: Int,
Copy link
Member

Choose a reason for hiding this comment

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

selectedRoomsCount?

)
.clickable(
enabled = selectableSpaceRoom.isLastAdmin.not(),
// TODO
Copy link
Member

Choose a reason for hiding this comment

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

Missing TODO details here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes. I'll address this comment in the next PR, it's about a11y.

Comment on lines 25 to 32
val showQuickAction = rooms
.any { !it.isLastAdmin }

/**
* True if there are rooms and they are all selected.
*/
val areAllSelected = rooms
.filter { !it.isLastAdmin }
Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal, but maybe we could reuse the rooms.filter here for the .any above and the .all below instead of filtering the list 3 times? Since it'll be a small list (probably) maybe it's not worth it.

),
)
// By default select all rooms
selectedRoomIds.value = rooms.map { it.roomId }.toSet()
Copy link
Member

@jmartinesp jmartinesp Sep 26, 2025

Choose a reason for hiding this comment

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

Should this be an immutable set so it won't trigger unnecessary recompositions? As in using ImmutableSet instead of Set for the value.

@bmarty bmarty enabled auto-merge September 26, 2025 14:29
Copy link

@bmarty bmarty merged commit 59df60a into develop Sep 26, 2025
28 of 29 checks passed
@bmarty bmarty deleted the feature/bma/leaveSpace branch September 26, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Wip For anything that isn't ready to ship and will be enabled at a later date
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Add a More menu to the SpaceScreen.
3 participants