mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 01:15:54 +03:00
Also apply the filter to banned user screen
This commit is contained in:
parent
6147a87e46
commit
c0842d4da7
7 changed files with 64 additions and 28 deletions
|
@ -11,7 +11,7 @@ Improvements 🙌:
|
|||
- Small optimisation of scrolling experience in timeline (#2114)
|
||||
- Allow user to reset cross signing if he has no way to recover (#2052)
|
||||
- Create home shortcut for any room (#1525)
|
||||
- Filter room member by name (#2184)
|
||||
- Filter room member (and banned users) by name (#2184)
|
||||
|
||||
Bugfix 🐛:
|
||||
- Improve support for image/audio/video/file selection with intent changes (#1376)
|
||||
|
|
|
@ -22,4 +22,5 @@ import im.vector.app.core.platform.VectorViewModelAction
|
|||
sealed class RoomBannedListMemberAction : VectorViewModelAction {
|
||||
data class QueryInfo(val roomMemberSummary: RoomMemberSummary) : RoomBannedListMemberAction()
|
||||
data class UnBanUser(val roomMemberSummary: RoomMemberSummary) : RoomBannedListMemberAction()
|
||||
data class Filter(val filter: String) : RoomBannedListMemberAction()
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.matrix.android.sdk.internal.util.awaitCallback
|
|||
import org.matrix.android.sdk.rx.rx
|
||||
import org.matrix.android.sdk.rx.unwrap
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.features.powerlevel.PowerLevelsObservableFactory
|
||||
|
@ -90,6 +91,15 @@ class RoomBannedListMemberViewModel @AssistedInject constructor(@Assisted initia
|
|||
when (action) {
|
||||
is RoomBannedListMemberAction.QueryInfo -> onQueryBanInfo(action.roomMemberSummary)
|
||||
is RoomBannedListMemberAction.UnBanUser -> unBanUser(action.roomMemberSummary)
|
||||
is RoomBannedListMemberAction.Filter -> handleFilter(action)
|
||||
}.exhaustive
|
||||
}
|
||||
|
||||
private fun handleFilter(action: RoomBannedListMemberAction.Filter) {
|
||||
setState {
|
||||
copy(
|
||||
filter = action.filter
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
package im.vector.app.features.roomprofile.banned
|
||||
|
||||
import com.airbnb.epoxy.TypedEpoxyController
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.dividerItem
|
||||
import im.vector.app.core.epoxy.profiles.buildProfileSection
|
||||
|
@ -28,11 +26,15 @@ import im.vector.app.core.resources.ColorProvider
|
|||
import im.vector.app.core.resources.StringProvider
|
||||
import im.vector.app.core.ui.list.genericFooterItem
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.roomprofile.members.RoomMemberSummaryFilter
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import javax.inject.Inject
|
||||
|
||||
class RoomBannedMemberListController @Inject constructor(
|
||||
private val avatarRenderer: AvatarRenderer,
|
||||
private val stringProvider: StringProvider,
|
||||
private val roomMemberSummaryFilter: RoomMemberSummaryFilter,
|
||||
colorProvider: ColorProvider
|
||||
) : TypedEpoxyController<RoomBannedMemberListViewState>() {
|
||||
|
||||
|
@ -63,34 +65,37 @@ class RoomBannedMemberListController @Inject constructor(
|
|||
} else {
|
||||
buildProfileSection(quantityString)
|
||||
|
||||
bannedList.join(
|
||||
each = { _, roomMember ->
|
||||
val actionInProgress = data.onGoingModerationAction.contains(roomMember.userId)
|
||||
profileMatrixItemWithProgress {
|
||||
id(roomMember.userId)
|
||||
matrixItem(roomMember.toMatrixItem())
|
||||
avatarRenderer(avatarRenderer)
|
||||
apply {
|
||||
if (actionInProgress) {
|
||||
inProgress(true)
|
||||
editable(false)
|
||||
} else {
|
||||
inProgress(false)
|
||||
editable(true)
|
||||
clickListener { _ ->
|
||||
callback?.onUnbanClicked(roomMember)
|
||||
roomMemberSummaryFilter.filter = data.filter
|
||||
bannedList
|
||||
.filter { roomMemberSummaryFilter.test(it) }
|
||||
.join(
|
||||
each = { _, roomMember ->
|
||||
val actionInProgress = data.onGoingModerationAction.contains(roomMember.userId)
|
||||
profileMatrixItemWithProgress {
|
||||
id(roomMember.userId)
|
||||
matrixItem(roomMember.toMatrixItem())
|
||||
avatarRenderer(avatarRenderer)
|
||||
apply {
|
||||
if (actionInProgress) {
|
||||
inProgress(true)
|
||||
editable(false)
|
||||
} else {
|
||||
inProgress(false)
|
||||
editable(true)
|
||||
clickListener { _ ->
|
||||
callback?.onUnbanClicked(roomMember)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
between = { _, roomMemberBefore ->
|
||||
dividerItem {
|
||||
id("divider_${roomMemberBefore.userId}")
|
||||
color(dividerColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
between = { _, roomMemberBefore ->
|
||||
dividerItem {
|
||||
id("divider_${roomMemberBefore.userId}")
|
||||
color(dividerColor)
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package im.vector.app.features.roomprofile.banned
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.isVisible
|
||||
import com.airbnb.mvrx.args
|
||||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
|
@ -53,6 +55,7 @@ class RoomBannedMemberListFragment @Inject constructor(
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
roomMemberListController.callback = this
|
||||
setupToolbar(roomSettingsToolbar)
|
||||
setupSearchView()
|
||||
recyclerView.configureWith(roomMemberListController, hasFixedSize = true)
|
||||
|
||||
viewModel.observeViewEvents {
|
||||
|
@ -84,6 +87,21 @@ class RoomBannedMemberListFragment @Inject constructor(
|
|||
super.onDestroyView()
|
||||
}
|
||||
|
||||
private fun setupSearchView() {
|
||||
searchViewAppBarLayout.isVisible = true
|
||||
searchView.queryHint = getString(R.string.search_banned_user_hint)
|
||||
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onQueryTextChange(newText: String): Boolean {
|
||||
viewModel.handle(RoomBannedListMemberAction.Filter(newText))
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun invalidate() = withState(viewModel) { viewState ->
|
||||
roomMemberListController.setData(viewState)
|
||||
renderRoomSummary(viewState)
|
||||
|
|
|
@ -27,6 +27,7 @@ data class RoomBannedMemberListViewState(
|
|||
val roomId: String,
|
||||
val roomSummary: Async<RoomSummary> = Uninitialized,
|
||||
val bannedMemberSummaries: Async<List<RoomMemberSummary>> = Uninitialized,
|
||||
val filter: String = "",
|
||||
val onGoingModerationAction: List<String> = emptyList(),
|
||||
val canUserBan: Boolean = false
|
||||
) : MvRxState {
|
||||
|
|
|
@ -623,6 +623,7 @@
|
|||
<!-- Search -->
|
||||
<string name="search_hint">Search</string>
|
||||
<string name="search_members_hint">Filter room members</string>
|
||||
<string name="search_banned_user_hint">Filter banned users</string>
|
||||
<string name="search_no_results">No results</string>
|
||||
<string name="tab_title_search_rooms">ROOMS</string>
|
||||
<string name="tab_title_search_messages">MESSAGES</string>
|
||||
|
|
Loading…
Reference in a new issue