Small rework for nicer code

This commit is contained in:
Benoit Marty 2022-05-24 14:56:13 +02:00 committed by Benoit Marty
parent 6a728e3851
commit 2b0077b138
1 changed files with 9 additions and 7 deletions

View File

@ -268,13 +268,7 @@ internal class RoomSummaryDataSource @Inject constructor(
val query = with(queryStringValueProcessor) {
RoomSummaryEntity.where(realm)
.process(RoomSummaryEntityFields.ROOM_ID, QueryStringValue.IsNotEmpty)
.let {
if (queryParams.displayName.isNormalized()) {
it.process(RoomSummaryEntityFields.NORMALIZED_DISPLAY_NAME, queryParams.displayName)
} else {
it.process(RoomSummaryEntityFields.DISPLAY_NAME, queryParams.displayName)
}
}
.process(queryParams.displayName.toDisplayNameField(), queryParams.displayName)
.process(RoomSummaryEntityFields.CANONICAL_ALIAS, queryParams.canonicalAlias)
.process(RoomSummaryEntityFields.MEMBERSHIP_STR, queryParams.memberships)
.equalTo(RoomSummaryEntityFields.IS_HIDDEN_FROM_USER, false)
@ -342,6 +336,14 @@ internal class RoomSummaryDataSource @Inject constructor(
return query
}
private fun QueryStringValue.toDisplayNameField(): String {
return if (isNormalized()) {
RoomSummaryEntityFields.NORMALIZED_DISPLAY_NAME
} else {
RoomSummaryEntityFields.DISPLAY_NAME
}
}
fun getAllRoomSummaryChildOf(spaceAliasOrId: String, memberShips: List<Membership>): List<RoomSummary> {
val space = getSpaceSummary(spaceAliasOrId) ?: return emptyList()
val result = ArrayList<RoomSummary>()