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

Replaces subtitle in Search Rooms with room context rather than last event #5860

Merged
merged 24 commits into from
May 30, 2022

Conversation

ericdecanini
Copy link
Contributor

@ericdecanini ericdecanini commented Apr 28, 2022

Drafting for early discussion purposes

Assignees assigned for taking a look at my query below, didn't want to overfill the reviewers section

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Instead of showing the last event (last message sent, etc.), room list items in the search screen will show room context (parent space, user id, canonical alias, etc)

Motivation and context

Closes #3943

This brings Android into parity with desktop clients.

Getting the space that the room belonged to was not as straightforward as initially expected. Spaces that rooms belonged to often weren't being saved properly into Realm which meant that rooms that belonged to spaces had an empty list of parents. This is why this PR contains updates to RoomSummaryUpdater and related classes

Other changes in this PR include: Centering of the room title when the subtitle is empty

I also took this opportunity to cleanup some commented code

Screenshots / GIFs

Before After
image image

As you can see above, for space rooms, we show the space or subspace they belong to. For non-space rooms, we show their alias if its available. For dms, we show the user id of the other recipient. Otherwise, we show nothing

Tests

  • From the home screen, navigate to the search screen (by clicking on the filter icon in the action bar)
  • Search for rooms in spaces, standalone rooms, dm rooms, dms, and rooms with aliases. See that the subtitle is appropriate for each of them and matches what you find on the desktop clients

Tested devices

  • Physical
  • Emulator
  • OS version(s): Android 10

Checklist

Comment on lines 366 to 371
childSum.parents.add(SpaceParentSummaryEntity(
canonical = true,
parentRoomId = parent.roomId,
parentSummaryEntity = parent,
viaServers = RealmList()
))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BillCarsonFr @bmarty @ganfra can you guys give me more context surrounding this please.

I added this block to add the parents of a room (spaces, etc) as they currently weren't being added, but the canonical = true and viaServers = RealmList() are currently placeholders as I don't know what they are or what they should be.

Copy link
Member

Choose a reason for hiding this comment

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

You should remove this part. Parent is only for m.space.parent state event.
We are not adding a parent link because you are a child.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does a child have no knowledge of its parent then, other than through flattenParentIds? This is confusing because each roomSummary has the field spaceParents which is currently often empty.

Ultimately as well, we would like to be able to know a room's parent in its summary object so we can achieve the same as what web does here (the space of the room is displayed in search)

image

Copy link
Member

Choose a reason for hiding this comment

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

Yes parent is really when there is a m.space.parent state event in the room (and a valid one, added by an admin in both rooms).
It's not really used right now, it's more to help for discovery, when you join a room from a link the UI could prompt a tip to propose you to join the space.

I think you can use flattenParentsIds for the use case you mentioned.

Comment on lines 375 to 378
if (childSum.flattenParentIds?.isEmpty() == false) {
childSum.flattenParentIds += "|"
}
childSum.flattenParentIds += it
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes a bug where the first element of flattenParentIds would always be ""

Copy link
Member

Choose a reason for hiding this comment

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

Why is it a bug? What was not working?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

E.g. if a room had one parent, its roomSummary.flattenParentIds would be {"", "parentRoomId"}

Idk if it has any user-facing impact but I believe this isn't expected behaviour in the code

Copy link
Member

Choose a reason for hiding this comment

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

I am surprised we didn't get report on this, maybe the RoomSummaryMapper is doing some cleaning? None the less I would submit this as a separate PR.

@github-actions
Copy link

github-actions bot commented Apr 28, 2022

Unit Test Results

124 files  +  2  124 suites  +2   2m 9s ⏱️ -14s
220 tests +15  220 ✔️ +15  0 💤 ±0  0 ±0 
726 runs  +36  726 ✔️ +36  0 💤 ±0  0 ±0 

Results for commit a5dc8ec. ± Comparison against base commit 4309fdb.

This pull request removes 5 and adds 20 tests. Note that renamed tests count towards both.
im.vector.app.features.onboarding.OnboardingViewModelTest ‑ given changing profile picture is not supported, when updating display name, then updates upstream user display name and completes personalization
im.vector.app.features.onboarding.OnboardingViewModelTest ‑ given changing profile picture is supported, when updating display name, then updates upstream user display name and moves to choose profile picture
im.vector.app.features.onboarding.OnboardingViewModelTest ‑ given personalisation enabled and registration has started and has dummy step to do, when handling action, then ignores other steps and executes dummy
im.vector.app.features.onboarding.ftueauth.FtueMissingRegistrationStagesComparatorTest ‑ when ordering stages, then prioritizes email
org.matrix.android.sdk.internal.session.pushers.DefaultAddPusherTaskTest ‑ given a persisted push entity and SetPush API fails when adding Pusher then mutates persisted result with Failed registration state and rethrows error
im.vector.app.features.onboarding.OnboardingViewModelTest ‑ given changing profile avatar is not supported, when updating display name, then updates upstream user display name and completes personalization
im.vector.app.features.onboarding.OnboardingViewModelTest ‑ given changing profile avatar is supported, when updating display name, then updates upstream user display name and moves to choose profile avatar
im.vector.app.features.onboarding.OnboardingViewModelTest ‑ given personalisation enabled and registration has started and has dummy step to do, when handling action, then ignores other steps and does dummy
im.vector.app.features.onboarding.RegistrationActionHandlerTest ‑ given adding an email ThreePid fails with 401, when handling register action, then infer EmailSuccess
im.vector.app.features.onboarding.RegistrationActionHandlerTest ‑ given email verification errors with 401 and succeeds, when checking email validation, then continues to poll until success
im.vector.app.features.onboarding.RegistrationActionHandlerTest ‑ given email verification errors with 401 then fatal error, when checking email validation, then continues to poll until non 401 error
im.vector.app.features.onboarding.ftueauth.MatrixOrgRegistrationStagesComparatorTest ‑ when ordering stages, then prioritizes email
org.matrix.android.sdk.internal.session.pushers.DefaultAddPusherTaskTest ‑ given a persisted push entity and SetPush API fails when adding Pusher then mutates persisted result with Failed registration state and rethrows
org.matrix.android.sdk.internal.session.room.aggregation.poll.PollAggregationProcessorTest ‑ given a poll end event for my own poll without enough redaction power level, when processing, then is processed and returns true
org.matrix.android.sdk.internal.session.room.aggregation.poll.PollAggregationProcessorTest ‑ given a poll end event without enough redaction power level, when is processed, then is ignored and return false
…

♻️ This comment has been updated with latest results.

@@ -26,7 +27,7 @@ class RoomSummaryListController(

override fun buildModels(data: List<RoomSummary>?) {
data?.forEach {
add(roomSummaryItemFactory.create(it, emptyMap(), emptySet(), listener))
add(roomSummaryItemFactory.create(it, emptyMap(), emptySet(), RoomListDisplayMode.ROOMS /* TODO: change */, listener))
Copy link
Member

Choose a reason for hiding this comment

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

TODO?

Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

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

Thx, please see my comments.

@ericdecanini ericdecanini marked this pull request as ready for review May 3, 2022 08:06
)
}
}
roomSummary.copy(spaceParents = parents)
Copy link
Member

@BillCarsonFr BillCarsonFr May 3, 2022

Choose a reason for hiding this comment

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

it doesn't feel right to copy flattenParents into spaceParents (supposed to be the real m.space.parent)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't wanna do this or the approach done earlier, do we have any way of knowing a room's space parent? (when there isn't a space parent event occurring)

Copy link
Member

@BillCarsonFr BillCarsonFr May 6, 2022

Choose a reason for hiding this comment

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

I mean you could do like that but maybe create a new field in the RoomSummary model like flattenParents or any name that would mean parent or grand parent, etc.. or childOf. It's just to reflect that it's the consequence of a m.space.childrelation and not of a m.space.parent. You could then have a list of RoomSummary and not ParentInfo that needs a viaServer/canonical info.

Other solution could be to get the roomSummary from the flattenParentsIds in the view model.

@ericdecanini ericdecanini requested a review from BillCarsonFr May 4, 2022 08:30
@bmarty
Copy link
Member

bmarty commented May 5, 2022

It could be better to show the last message when nothing else is displayed. Or at least ensure that the room name is centered vertically in this case.

@ericdecanini
Copy link
Contributor Author

It could be better to show the last message when nothing else is displayed. Or at least ensure that the room name is centered vertically in this case.

The current behaviour is in parity with web and desktop's "New Search". Imo it would be better to get into parity with them and if it's not the behaviour we want we can raise a meta issue to fix it across all platforms.

This would be a design decision at the end of the day. @niquewoodhouse what do you think?

@niquewoodhouse
Copy link

It could be better to show the last message when nothing else is displayed. Or at least ensure that the room name is centered vertically in this case.

The current behaviour is in parity with web and desktop's "New Search". Imo it would be better to get into parity with them and if it's not the behaviour we want we can raise a meta issue to fix it across all platforms.

This would be a design decision at the end of the day. @niquewoodhouse what do you think?

I'd rather have parity with web too. I think its rare last message would be helpful in this circumstance, but we should be able to find out in testing and feedback

@bmarty
Copy link
Member

bmarty commented May 9, 2022

Ok, then can you try to center vertically the room name please?

image

is quite not good from a design perspective, it looks like a bug: "nothing is displayed on the second line"

We already have such centering mechanism when subtitle is missing for the room aliases for instance:

image

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Just blocking on the way you center text in the item_room.xml.
Happy to discuss this more.
Did not review anything else on this PR.

android:layout_height="15dp"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/topMarginSpace" />
Copy link
Member

Choose a reason for hiding this comment

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

weird way to align text vertically. If the font size is changed, it will not work properly.
Is is possible to do better using ConstraintLayout attributes?
Maybe adding a new sublayout if there is no easier solution.

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 tried this with changing consraints programatically, but that affects other bindings as you scroll. There's no easy way to 'reset' the view to its original xml state.

Can you explain more what you mean by sublayout?

Copy link
Member

Choose a reason for hiding this comment

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

sublayout: add a new ConstraintLayout to pack the Title and the Subtitle.
I did not check if this is possible, there are other views around.
I will try to play a bit on this layout to see if I find something better.

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 think the best way to do this imo is to inflate an entirely different Epoxy item based on whether there is a subtitle or not. What are your thoughts on that?

Copy link
Member

Choose a reason for hiding this comment

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

I will improve that in the future, there is another bug related, with the placeholder.

Copy link
Contributor 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.

Thanks. I am removing myself from the reviewer now.

@ericdecanini ericdecanini requested a review from bmarty May 17, 2022 16:04
@bmarty bmarty requested review from bmarty and removed request for bmarty May 23, 2022 10:44
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

(Did not make a full review)

@bmarty bmarty removed their assignment May 23, 2022
@@ -193,7 +194,7 @@ internal class RoomSummaryDataSource @Inject constructor(
}
val dataSourceFactory = realmDataSourceFactory.map {
roomSummaryMapper.map(it)
}
}.map { it.getWithParents() }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be cool to have an overload of map in RoomSummaryMapper to have a param to request flattened parent

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better also. Like that it won't impact perf for those who don't need to load additional things?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout!

private fun RoomSummary.getWithParents(): RoomSummary {
val parents = flattenParentIds.mapNotNull { parentId ->
getRoomSummary(parentId)?.let { parentSummary ->
SpaceParentInfo(
Copy link
Member

Choose a reason for hiding this comment

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

Why not just return the RoomSummaries here instead of fake parentInfo with fake/wrong canonical & viaservers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Idk why I didn't do this to start with lmao

Copy link
Member

Choose a reason for hiding this comment

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

👍

@fedrunov fedrunov self-requested a review May 30, 2022 08:13
@ericdecanini ericdecanini merged commit eeb7d60 into develop May 30, 2022
@ericdecanini ericdecanini deleted the feature/eric/replace-search-room-subheader branch May 30, 2022 09:13
@github-actions
Copy link

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
  • [org.matrix.android.sdk.account]
    = passed=3 failures=0 errors=0 skipped=2
  • [org.matrix.android.sdk.internal]
    = passed=21 failures=1 errors=0 skipped=1
  • [org.matrix.android.sdk.ordering]
    = passed=16 failures=0 errors=0 skipped=0
  • [org.matrix.android.sdk.PermalinkParserTest]
    = passed=2 failures=0 errors=0 skipped=0

@fedrunov fedrunov mentioned this pull request Jun 6, 2022
9 tasks
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.

Not able to see which General is which in Filter/Search
6 participants