diff --git a/vector/src/main/java/im/vector/app/features/home/SpaceListModalFragment.kt b/vector/src/main/java/im/vector/app/features/home/SpaceListModalFragment.kt index 498d50f1d2..cf8dcd2479 100644 --- a/vector/src/main/java/im/vector/app/features/home/SpaceListModalFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/SpaceListModalFragment.kt @@ -28,10 +28,12 @@ import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentSpaceListModalBinding +import im.vector.app.features.home.room.list.UnreadCounterBadgeView import im.vector.app.features.spaces.SpaceListAction import im.vector.app.features.spaces.SpaceListViewModel import im.vector.app.features.spaces.manage.ManageType import im.vector.app.features.spaces.manage.SpaceManageActivity +import timber.log.Timber import javax.inject.Inject @AndroidEntryPoint @@ -92,6 +94,9 @@ class SpaceListModalFragment : VectorBaseFragment (binding.roomList.adapter as SpaceListAdapter).replaceList(it) binding.noSpacesYetGroup.isVisible = it.isEmpty() } + + binding.invitesGroup.isVisible = state.inviteCount > 0 + binding.counterBadge.render(UnreadCounterBadgeView.State(state.inviteCount, true)) } } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt index a6761ef557..e38aaa38be 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt @@ -142,7 +142,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa ) setState { copy( - homeAggregateCount = counts + homeAggregateCount = counts, ) } } @@ -285,19 +285,16 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa displayName = QueryStringValue.IsNotEmpty } - combine( - session.flow() - .liveSpaceSummaries(params), + combine(session.flow().liveSpaceSummaries(params), session.accountDataService() .getLiveRoomAccountDataEvents(setOf(RoomAccountDataTypes.EVENT_TYPE_SPACE_ORDER)) .asFlow() - ) { spaces, _ -> - spaces - }.execute { async -> + ) { spaces, _ -> spaces }.execute { async -> asyncSpaceList = async val currentSpaceChildren = currentSpace?.let { space -> async.invoke()?.filter { it.flattenParentIds.contains(space.roomId) } } val rootSpaces = async.invoke().orEmpty().filter { it.flattenParentIds.isEmpty() } - val displaySpaces = currentSpaceChildren ?: rootSpaces + val displaySpaces = (currentSpaceChildren ?: rootSpaces).filter { it.inviterId == null } + val inviteSpaces = (currentSpaceChildren ?: rootSpaces).filter { it.inviterId != null } val orders = displaySpaces.associate { it.roomId to session.getRoom(it.roomId) ?.roomAccountDataService() @@ -308,6 +305,8 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa copy( asyncSpaces = async, rootSpacesOrdered = displaySpaces.sortedWith(TopLevelSpaceComparator(orders)), + inviteSpaces = inviteSpaces.sortedWith(TopLevelSpaceComparator(orders)), + inviteCount = inviteSpaces.size, spaceOrderInfo = orders ) } @@ -326,7 +325,8 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa private fun emitSpaceViewState() = asyncSpaceList?.let { async -> val currentSpaceChildren = currentSpace?.let { space -> asyncSpaceList?.invoke()?.filter { it.flattenParentIds.contains(space.roomId) } } val rootSpaces = asyncSpaceList?.invoke().orEmpty().filter { it.flattenParentIds.isEmpty() } - val displaySpaces = currentSpaceChildren ?: rootSpaces + val displaySpaces = (currentSpaceChildren ?: rootSpaces).filter { it.inviterId == null } + val inviteSpaces = (currentSpaceChildren ?: rootSpaces).filter { it.inviterId != null } val orders = displaySpaces.associate { it.roomId to session.getRoom(it.roomId) ?.roomAccountDataService() @@ -338,6 +338,8 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa copy( asyncSpaces = async, rootSpacesOrdered = displaySpaces.sortedWith(TopLevelSpaceComparator(orders)), + inviteSpaces = inviteSpaces.sortedWith(TopLevelSpaceComparator(orders)), + inviteCount = inviteSpaces.size, spaceOrderInfo = orders ) } diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewState.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewState.kt index eafc6a241e..daeabdf34f 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewState.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewState.kt @@ -30,9 +30,11 @@ data class SpaceListViewState( val asyncSpaces: Async> = Uninitialized, val selectedGroupingMethod: RoomGroupingMethod = RoomGroupingMethod.BySpace(null), val rootSpacesOrdered: List? = null, + val inviteSpaces: List? = null, val spaceOrderInfo: Map? = null, val spaceOrderLocalEchos: Map? = null, val legacyGroups: List? = null, val expandedStates: Map = emptyMap(), + val inviteCount: Int = 0, val homeAggregateCount: RoomAggregateNotificationCount = RoomAggregateNotificationCount(0, 0) ) : MavericksState diff --git a/vector/src/main/res/layout/fragment_space_list_modal.xml b/vector/src/main/res/layout/fragment_space_list_modal.xml index 1074677b79..f5465d7d68 100644 --- a/vector/src/main/res/layout/fragment_space_list_modal.xml +++ b/vector/src/main/res/layout/fragment_space_list_modal.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent" android:background="@drawable/bg_space_modal"> - - + + + + + + + Screen sharing is in progress All Chats Spaces + Invites Chats No spaces yet Add spaces to group your chats