Support only notif display mode

+ code quality fixes
This commit is contained in:
Valere 2021-03-31 12:31:02 +02:00 committed by Benoit Marty
parent 52f98dc405
commit 41176c3e26
5 changed files with 22 additions and 9 deletions

View File

@ -27,6 +27,7 @@ fun roomSummaryQueryParams(init: (RoomSummaryQueryParams.Builder.() -> Unit) = {
enum class RoomCategoryFilter {
ONLY_DM,
ONLY_ROOMS,
ONLY_WITH_NOTIFICATIONS,
ALL
}

View File

@ -181,6 +181,7 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
when (it) {
RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false)
RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0)
RoomCategoryFilter.ALL -> {
// nop
}

View File

@ -161,7 +161,7 @@ Formatter\.formatShortFileSize===1
# android\.text\.TextUtils
### This is not a rule, but a warning: the number of "enum class" has changed. For Json classes, it is mandatory that they have `@JsonClass(generateAdapter = false)`. If the enum is not used as a Json class, change the value in file forbidden_strings_in_code.txt
enum class===93
enum class===94
### Do not import temporary legacy classes
import org.matrix.android.sdk.internal.legacy.riot===3

View File

@ -115,10 +115,11 @@ class HomeDetailViewModel @AssistedInject constructor(@Assisted initialState: Ho
}
private fun observeRoomSummaries() {
session.getPagedRoomSummariesLive(roomSummaryQueryParams {
session.getPagedRoomSummariesLive(
roomSummaryQueryParams {
memberships = Membership.activeMemberships()
})
.asObservable()
}
).asObservable()
.throttleFirst(300, TimeUnit.MILLISECONDS)
.subscribe {
val dmInvites = session.getRoomSummaries(roomSummaryQueryParams {

View File

@ -129,7 +129,6 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
} else if (initialState.displayMode == RoomListDisplayMode.FILTERED) {
withQueryParams({
it.memberships = Membership.activeMemberships()
// it.displayName = QueryStringValue.Contains("")
}) { qpm ->
val name = stringProvider.getString(R.string.bottom_action_rooms)
session.getFilteredPagedRoomSummariesLive(qpm)
@ -139,10 +138,21 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
}
}
}
sections
else if (initialState.displayMode == RoomListDisplayMode.NOTIFICATIONS) {
withQueryParams({
it.memberships = Membership.activeMemberships()
it.roomCategoryFilter = RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS
}) { qpm ->
val name = stringProvider.getString(R.string.bottom_action_rooms)
session.getFilteredPagedRoomSummariesLive(qpm)
.let { livePagedList ->
updatableQuery = livePagedList
sections.add(RoomsSection(name, livePagedList.livePagedList))
}
}
}
init {
sections
}
override fun handle(action: RoomListAction) {