Cleanup
This commit is contained in:
parent
ac8303bb99
commit
40907a71b6
|
@ -39,12 +39,6 @@ fun spaceSummaryQueryParams(init: (RoomSummaryQueryParams.Builder.() -> Unit) =
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class RoomCategoryFilter {
|
|
||||||
ONLY_DM,
|
|
||||||
ONLY_ROOMS,
|
|
||||||
ALL
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class can be used to filter room summaries to use with:
|
* This class can be used to filter room summaries to use with:
|
||||||
* [org.matrix.android.sdk.api.session.room.Room] and [org.matrix.android.sdk.api.session.room.RoomService]
|
* [org.matrix.android.sdk.api.session.room.Room] and [org.matrix.android.sdk.api.session.room.RoomService]
|
||||||
|
@ -59,11 +53,10 @@ data class RoomSummaryQueryParams(
|
||||||
val excludeType: List<String?>?,
|
val excludeType: List<String?>?,
|
||||||
val includeType: List<String?>?,
|
val includeType: List<String?>?,
|
||||||
val activeSpaceFilter: ActiveSpaceFilter?,
|
val activeSpaceFilter: ActiveSpaceFilter?,
|
||||||
var activeGroupId: String? = null
|
val activeGroupId: String? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
class Builder {
|
class Builder {
|
||||||
|
|
||||||
var roomId: QueryStringValue = QueryStringValue.IsNotEmpty
|
var roomId: QueryStringValue = QueryStringValue.IsNotEmpty
|
||||||
var displayName: QueryStringValue = QueryStringValue.IsNotEmpty
|
var displayName: QueryStringValue = QueryStringValue.IsNotEmpty
|
||||||
var canonicalAlias: QueryStringValue = QueryStringValue.NoCondition
|
var canonicalAlias: QueryStringValue = QueryStringValue.NoCondition
|
||||||
|
|
|
@ -247,10 +247,10 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
|
||||||
|
|
||||||
queryParams.roomCategoryFilter?.let {
|
queryParams.roomCategoryFilter?.let {
|
||||||
when (it) {
|
when (it) {
|
||||||
RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
|
RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
|
||||||
RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false)
|
RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false)
|
||||||
RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0)
|
RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0)
|
||||||
RoomCategoryFilter.ALL -> {
|
RoomCategoryFilter.ALL -> {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,15 +274,15 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
|
||||||
query.equalTo(RoomSummaryEntityFields.ROOM_TYPE, it)
|
query.equalTo(RoomSummaryEntityFields.ROOM_TYPE, it)
|
||||||
}
|
}
|
||||||
when (queryParams.roomCategoryFilter) {
|
when (queryParams.roomCategoryFilter) {
|
||||||
RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
|
RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
|
||||||
RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false)
|
RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false)
|
||||||
RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0)
|
RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0)
|
||||||
RoomCategoryFilter.ALL -> Unit // nop
|
RoomCategoryFilter.ALL -> Unit // nop
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timber.w("VAL: activeSpaceId : ${queryParams.activeSpaceId}")
|
// Timber.w("VAL: activeSpaceId : ${queryParams.activeSpaceId}")
|
||||||
when (queryParams.activeSpaceFilter) {
|
when (queryParams.activeSpaceFilter) {
|
||||||
is ActiveSpaceFilter.ActiveSpace -> {
|
is ActiveSpaceFilter.ActiveSpace -> {
|
||||||
// It's annoying but for now realm java does not support querying in primitive list :/
|
// It's annoying but for now realm java does not support querying in primitive list :/
|
||||||
// https://github.com/realm/realm-java/issues/5361
|
// https://github.com/realm/realm-java/issues/5361
|
||||||
if (queryParams.activeSpaceFilter.currentSpaceId == null) {
|
if (queryParams.activeSpaceFilter.currentSpaceId == null) {
|
||||||
|
@ -300,8 +300,8 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryParams.activeGroupId != null) {
|
queryParams.activeGroupId?.let { activeGroupId ->
|
||||||
query.contains(RoomSummaryEntityFields.GROUP_IDS, queryParams.activeGroupId!!)
|
query.contains(RoomSummaryEntityFields.GROUP_IDS, activeGroupId)
|
||||||
}
|
}
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue