-
Notifications
You must be signed in to change notification settings - Fork 731
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
Cleanup room summary query params #6143
Conversation
} | ||
).size | ||
|
||
roomsInvite = session.roomService().getRoomSummaries( | ||
roomSummaryQueryParams { | ||
memberships = listOf(Membership.INVITE) | ||
roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS | ||
activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(groupingMethod.spaceSummary?.roomId) | ||
spaceFilter = groupingMethod.spaceSummary?.roomId?.let { SpaceFilter.ActiveSpace(it) } ?: SpaceFilter.OrphanRooms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is equivalent (I think) to the previous code, hence, I am not sure why we would like to have OrphanRooms
here. I am tempted to remove the fallback and pass null
instead. WDYT @BillCarsonFr ?
Applicable to all the equivalent change in this file (and in other files too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could reduce some of the noise by extracting a fun GroupingMethod.activeSpaceOrNull() / orOphans
extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done c9a292c
) | ||
} else { | ||
copy( | ||
activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(currentSpace) | ||
spaceFilter = SpaceFilter.ActiveSpace(currentSpace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was tempted to rewrite to something like
spaceFilter = currentSpace?.let{ SpaceFilter.ActiveSpace(it) }
But I think this is better to keep it like that for code clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo it's still very clear and it would be nice to be consistent with the change above in line 439. There would be a slight difference in functionality though. What happens if we get SpaceFilter.ActiveSpace(null)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using null in SpaceFilter.ActiveSpace(null)
is not possible anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it.membership == Membership.JOIN | ||
} | ||
list.firstOrNull { it.roomId == initialState.roomId }?.roomType?.let { | ||
.liveRoomSummary(initialState.roomId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling a new API
// nop | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed because the same code is at line 302 below. Line 287 in the new version of the file.
it.process(RoomSummaryEntityFields.DISPLAY_NAME, queryParams.displayName) | ||
} | ||
} | ||
.process(RoomSummaryEntityFields.ROOM_ID, QueryStringValue.IsNotEmpty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep this check, even if I think we cannot have a room in DB with an empty Id.
This PR is not supposed to bring functional changes.
@@ -168,9 +168,6 @@ class SpaceAddRoomsViewModel @AssistedInject constructor( | |||
override fun handle(action: SpaceAddRoomActions) { | |||
when (action) { | |||
is SpaceAddRoomActions.UpdateFilter -> { | |||
roomUpdatableLivePageResult.queryParams = roomUpdatableLivePageResult.queryParams.copy( | |||
displayName = QueryStringValue.Contains(action.filter, QueryStringValue.Case.INSENSITIVE) | |||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed because the lines just below are the same.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
var canonicalAlias: QueryStringValue = QueryStringValue.NoCondition | ||
var memberships: List<Membership> = Membership.all() | ||
var roomCategoryFilter: RoomCategoryFilter? = RoomCategoryFilter.ALL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I preferred the explicitness of the ALL
but null
is more consistent with the project conventions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I also prefer using non-nullability. For this specific API, it's more consistent to use null
.
@@ -28,65 +28,196 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent | |||
* It can be retrieved by [org.matrix.android.sdk.api.session.room.Room] and [org.matrix.android.sdk.api.session.room.RoomService] | |||
*/ | |||
data class RoomSummary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
@@ -333,6 +314,14 @@ internal class RoomSummaryDataSource @Inject constructor( | |||
return query | |||
} | |||
|
|||
private fun QueryStringValue.toDisplayNameField(): String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for extracting
}) | ||
} else { | ||
listOfNotNull( | ||
getRoomSummary(roomId)?.takeIf { it.membership == Membership.JOIN } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a difference between listOf(getRoomSummary())
and getRoomSummaries { this.roomId = QueryStringValue.Equals(roomId) }
?
I'm wondering if all the roomSummaries
fetching should be taking into account roomIdOrAlias
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RoomSummaryQueryParams.roomId
has been removed, so cannot be used anymore.
roomIdOrAlias
can be used, but I think for this particular case roomId
is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall! Just a couple comments
* A live [RoomSummary] associated with the room with id [roomId]. | ||
* You can observe this summary to get dynamic data from this room, even if the room is not joined yet | ||
*/ | ||
fun getRoomSummaryLive(roomId: String): LiveData<Optional<RoomSummary>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels a bit weird that this uses Optional
and the non-live version uses a nullable. Is it possible to use the same for both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LiveData
cannot emit null value IIRC.
) | ||
} else { | ||
copy( | ||
activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(currentSpace) | ||
spaceFilter = SpaceFilter.ActiveSpace(currentSpace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo it's still very clear and it would be nice to be consistent with the change above in line 439. There would be a slight difference in functionality though. What happens if we get SpaceFilter.ActiveSpace(null)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…ueryParams.Builder()` Also format and add some Kdoc
…ueryParams.Builder()` Also format and add some Kdoc
Create a new API in RoomService to observe a room summary from a roomId.
It was working fine since in the DB we always have a name using `RoomDisplayNameFallbackProvider`, which in our current implementation always return a non empty String.
Prefer nullability for API coherency of `RoomSummaryQueryParams`
Prefer nullability for API coherency of `RoomSummaryQueryParams`
Not 100% of the side effect. There is probably some (fixed?) bugs here.
f5194d3
to
ec498cf
Compare
Matrix SDKIntegration Tests Results:
|
Type of change
Content
No functional change on this PR.
Mainly work on
RoomSummaryQueryParams
, to try to match what we will have on the Rust SDK.Changes:
RoomSummaryQueryParams.roomId
. If you need to observe a single room, use the new APIRoomService.getRoomSummaryLive(roomId: String)
ActiveSpaceFilter
has been renamed toSpaceFilter
RoomCategoryFilter.ALL
has been removed, just passnull
to not filter on Room category.Remaining work:
Motivation and context
See content ^
Screenshots / GIFs
Tests
Tests are in progress
RoomService.getRoomSummaryLive(roomId: String)
: OKTested devices