Skip to content
Snippets Groups Projects
Commit 673cebb0 authored by Taras's avatar Taras
Browse files

Calculate and observe groups knovks

parent 24886436
No related branches found
No related tags found
No related merge requests found
...@@ -25,13 +25,19 @@ class GroupsDataSource @Inject constructor() { ...@@ -25,13 +25,19 @@ class GroupsDataSource @Inject constructor() {
private fun buildList(groups: List<RoomSummary>): List<GroupListItem> { private fun buildList(groups: List<RoomSummary>): List<GroupListItem> {
val joinedGroups = groups.filter { it.membership == Membership.JOIN } val joinedGroups = groups
.filter { it.membership == Membership.JOIN }
.map { it.toJoinedGroupListItem() }
val invitesCount = groups.filter { it.membership == Membership.INVITE }.size val invitesCount = groups.filter { it.membership == Membership.INVITE }.size
var knocksCount = 0
joinedGroups.forEach { knocksCount += it.knockRequestsCount }
return mutableListOf<GroupListItem>().apply { return mutableListOf<GroupListItem>().apply {
if (invitesCount > 0) if (invitesCount > 0 || knocksCount > 0)
add(GroupInvitesNotificationListItem(invitesCount)) add(GroupInvitesNotificationListItem(invitesCount, knocksCount))
addAll(joinedGroups.map { it.toJoinedGroupListItem() }) addAll(joinedGroups)
} }
} }
} }
\ No newline at end of file
...@@ -19,5 +19,6 @@ data class JoinedGroupListItem( ...@@ -19,5 +19,6 @@ data class JoinedGroupListItem(
) : GroupListItem(id) ) : GroupListItem(id)
data class GroupInvitesNotificationListItem( data class GroupInvitesNotificationListItem(
val invitesCount: Int val invitesCount: Int,
val knockRequestsCount: Int
) : GroupListItem("GroupInvitesNotificationListItem") ) : GroupListItem("GroupInvitesNotificationListItem")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment