Spaces | Personal spaces add DM - Web Parity #3271
This commit is contained in:
parent
abf7e275a7
commit
ae5a5ec92b
|
@ -344,10 +344,9 @@ internal class RoomSummaryUpdater @Inject constructor(
|
||||||
if (it != null) addAll(it)
|
if (it != null) addAll(it)
|
||||||
}
|
}
|
||||||
}.distinct()
|
}.distinct()
|
||||||
if (flattenRelated.isEmpty()) {
|
if (flattenRelated.isNotEmpty()) {
|
||||||
dmRoom.flattenParentIds = null
|
// we keep real m.child/m.parent relations and add the one for common memberships
|
||||||
} else {
|
dmRoom.flattenParentIds += "|${flattenRelated.joinToString("|")}|"
|
||||||
dmRoom.flattenParentIds = "|${flattenRelated.joinToString("|")}|"
|
|
||||||
}
|
}
|
||||||
// Timber.v("## SPACES: flatten of ${dmRoom.otherMemberIds.joinToString(",")} is ${dmRoom.flattenParentIds}")
|
// Timber.v("## SPACES: flatten of ${dmRoom.otherMemberIds.joinToString(",")} is ${dmRoom.flattenParentIds}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.airbnb.mvrx.Loading
|
import com.airbnb.mvrx.Loading
|
||||||
import com.airbnb.mvrx.activityViewModel
|
import com.airbnb.mvrx.activityViewModel
|
||||||
import com.airbnb.mvrx.fragmentViewModel
|
import com.airbnb.mvrx.fragmentViewModel
|
||||||
|
import com.airbnb.mvrx.withState
|
||||||
import com.jakewharton.rxbinding3.appcompat.queryTextChanges
|
import com.jakewharton.rxbinding3.appcompat.queryTextChanges
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.extensions.cleanup
|
import im.vector.app.core.extensions.cleanup
|
||||||
|
@ -42,6 +43,7 @@ import javax.inject.Inject
|
||||||
class SpaceAddRoomFragment @Inject constructor(
|
class SpaceAddRoomFragment @Inject constructor(
|
||||||
private val spaceEpoxyController: AddRoomListController,
|
private val spaceEpoxyController: AddRoomListController,
|
||||||
private val roomEpoxyController: AddRoomListController,
|
private val roomEpoxyController: AddRoomListController,
|
||||||
|
private val dmEpoxyController: AddRoomListController,
|
||||||
private val viewModelFactory: SpaceAddRoomsViewModel.Factory
|
private val viewModelFactory: SpaceAddRoomsViewModel.Factory
|
||||||
) : VectorBaseFragment<FragmentSpaceAddRoomsBinding>(),
|
) : VectorBaseFragment<FragmentSpaceAddRoomsBinding>(),
|
||||||
OnBackPressed, AddRoomListController.Listener, SpaceAddRoomsViewModel.Factory {
|
OnBackPressed, AddRoomListController.Listener, SpaceAddRoomsViewModel.Factory {
|
||||||
|
@ -84,6 +86,7 @@ class SpaceAddRoomFragment @Inject constructor(
|
||||||
viewModel.selectionListLiveData.observe(viewLifecycleOwner) {
|
viewModel.selectionListLiveData.observe(viewLifecycleOwner) {
|
||||||
spaceEpoxyController.selectedItems = it
|
spaceEpoxyController.selectedItems = it
|
||||||
roomEpoxyController.selectedItems = it
|
roomEpoxyController.selectedItems = it
|
||||||
|
dmEpoxyController.selectedItems = it
|
||||||
saveNeeded = it.values.any { it }
|
saveNeeded = it.values.any { it }
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
|
@ -95,6 +98,7 @@ class SpaceAddRoomFragment @Inject constructor(
|
||||||
viewModel.selectSubscribe(this, SpaceAddRoomsState::ignoreRooms) {
|
viewModel.selectSubscribe(this, SpaceAddRoomsState::ignoreRooms) {
|
||||||
spaceEpoxyController.ignoreRooms = it
|
spaceEpoxyController.ignoreRooms = it
|
||||||
roomEpoxyController.ignoreRooms = it
|
roomEpoxyController.ignoreRooms = it
|
||||||
|
dmEpoxyController.ignoreRooms = it
|
||||||
}.disposeOnDestroyView()
|
}.disposeOnDestroyView()
|
||||||
|
|
||||||
viewModel.selectSubscribe(this, SpaceAddRoomsState::isSaving) {
|
viewModel.selectSubscribe(this, SpaceAddRoomsState::isSaving) {
|
||||||
|
@ -149,6 +153,7 @@ class SpaceAddRoomFragment @Inject constructor(
|
||||||
views.roomList.cleanup()
|
views.roomList.cleanup()
|
||||||
spaceEpoxyController.listener = null
|
spaceEpoxyController.listener = null
|
||||||
roomEpoxyController.listener = null
|
roomEpoxyController.listener = null
|
||||||
|
dmEpoxyController.listener = null
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +186,21 @@ class SpaceAddRoomFragment @Inject constructor(
|
||||||
concatAdapter.addAdapter(roomEpoxyController.adapter)
|
concatAdapter.addAdapter(roomEpoxyController.adapter)
|
||||||
concatAdapter.addAdapter(spaceEpoxyController.adapter)
|
concatAdapter.addAdapter(spaceEpoxyController.adapter)
|
||||||
|
|
||||||
|
val shouldShowDm = withState(viewModel) { it.shouldShowDMs }
|
||||||
|
if (shouldShowDm) {
|
||||||
|
viewModel.updatableDMLivePageResult.liveBoundaries.observe(viewLifecycleOwner) {
|
||||||
|
dmEpoxyController.boundaryChange(it)
|
||||||
|
}
|
||||||
|
viewModel.updatableDMLivePageResult.livePagedList.observe(viewLifecycleOwner) {
|
||||||
|
dmEpoxyController.totalSize = it.size
|
||||||
|
dmEpoxyController.submitList(it)
|
||||||
|
}
|
||||||
|
dmEpoxyController.sectionName = getString(R.string.direct_chats_header)
|
||||||
|
dmEpoxyController.listener = this
|
||||||
|
|
||||||
|
concatAdapter.addAdapter(dmEpoxyController.adapter)
|
||||||
|
}
|
||||||
|
|
||||||
views.roomList.adapter = concatAdapter
|
views.roomList.adapter = concatAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@ data class SpaceAddRoomsState(
|
||||||
val currentFilter: String = "",
|
val currentFilter: String = "",
|
||||||
val spaceName: String = "",
|
val spaceName: String = "",
|
||||||
val ignoreRooms: List<String> = emptyList(),
|
val ignoreRooms: List<String> = emptyList(),
|
||||||
val isSaving: Async<List<String>> = Uninitialized
|
val isSaving: Async<List<String>> = Uninitialized,
|
||||||
|
val shouldShowDMs : Boolean = false
|
||||||
// val selectionList: Map<String, Boolean> = emptyMap()
|
// val selectionList: Map<String, Boolean> = emptyMap()
|
||||||
) : MvRxState {
|
) : MvRxState {
|
||||||
constructor(args: SpaceManageArgs) : this(
|
constructor(args: SpaceManageArgs) : this(
|
||||||
|
|
|
@ -98,6 +98,26 @@ class SpaceAddRoomsViewModel @AssistedInject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val updatableDMLivePageResult: UpdatableLivePageResult by lazy {
|
||||||
|
session.getFilteredPagedRoomSummariesLive(
|
||||||
|
roomSummaryQueryParams {
|
||||||
|
this.memberships = listOf(Membership.JOIN)
|
||||||
|
this.excludeType = listOf(RoomType.SPACE)
|
||||||
|
this.includeType = null
|
||||||
|
this.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
|
this.activeSpaceFilter = ActiveSpaceFilter.ExcludeSpace(initialState.spaceId)
|
||||||
|
this.displayName = QueryStringValue.Contains(initialState.currentFilter, QueryStringValue.Case.INSENSITIVE)
|
||||||
|
},
|
||||||
|
pagedListConfig = PagedList.Config.Builder()
|
||||||
|
.setPageSize(10)
|
||||||
|
.setInitialLoadSizeHint(20)
|
||||||
|
.setEnablePlaceholders(true)
|
||||||
|
.setPrefetchDistance(10)
|
||||||
|
.build(),
|
||||||
|
sortOrder = RoomSortOrder.NAME
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private val selectionList = mutableMapOf<String, Boolean>()
|
private val selectionList = mutableMapOf<String, Boolean>()
|
||||||
val selectionListLiveData = MutableLiveData<Map<String, Boolean>>()
|
val selectionListLiveData = MutableLiveData<Map<String, Boolean>>()
|
||||||
|
|
||||||
|
@ -106,7 +126,8 @@ class SpaceAddRoomsViewModel @AssistedInject constructor(
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
spaceName = spaceSummary?.displayName ?: "",
|
spaceName = spaceSummary?.displayName ?: "",
|
||||||
ignoreRooms = (spaceSummary?.flattenParentIds ?: emptyList()) + listOf(initialState.spaceId)
|
ignoreRooms = (spaceSummary?.flattenParentIds ?: emptyList()) + listOf(initialState.spaceId),
|
||||||
|
shouldShowDMs = spaceSummary?.isPublic == false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue