mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 23:13:38 +00:00
Cleanup
This commit is contained in:
parent
8b39c4e56a
commit
a295dfb248
@ -28,14 +28,12 @@ class BlockedContactsAdapter(val viewModel: BlockedContactsViewModel) : ListAdap
|
|||||||
.let(::ViewHolder)
|
.let(::ViewHolder)
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val selectable = getItem(position)
|
holder.bind(getItem(position), viewModel::toggle)
|
||||||
holder.bind(selectable, viewModel::toggle)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int, payloads: MutableList<Any>) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int, payloads: MutableList<Any>) {
|
||||||
val selectable = getItem(position)
|
if (payloads.isEmpty()) holder.bind(getItem(position), viewModel::toggle)
|
||||||
if (payloads.isEmpty()) holder.bind(selectable, viewModel::toggle)
|
else holder.select(getItem(position).isSelected)
|
||||||
else holder.select(selectable.isSelected)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewRecycled(holder: ViewHolder) {
|
override fun onViewRecycled(holder: ViewHolder) {
|
||||||
|
@ -31,7 +31,7 @@ class BlockedContactsViewModel @Inject constructor(private val storage: Storage)
|
|||||||
|
|
||||||
private val listUpdateChannel = Channel<Unit>(capacity = Channel.CONFLATED)
|
private val listUpdateChannel = Channel<Unit>(capacity = Channel.CONFLATED)
|
||||||
|
|
||||||
private val _state = MutableLiveData(BlockedContactsViewState(emptyList(), emptySet()))
|
private val _state = MutableLiveData(BlockedContactsViewState())
|
||||||
|
|
||||||
val state get() = _state.value!!
|
val state get() = _state.value!!
|
||||||
|
|
||||||
@ -110,12 +110,11 @@ class BlockedContactsViewModel @Inject constructor(private val storage: Storage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class BlockedContactsViewState(
|
data class BlockedContactsViewState(
|
||||||
val blockedContacts: List<Recipient>,
|
val blockedContacts: List<Recipient> = emptyList(),
|
||||||
val selectedItems: Set<Recipient>
|
val selectedItems: Set<Recipient> = emptySet()
|
||||||
) {
|
) {
|
||||||
val items = blockedContacts.map { SelectableItem(it, it in selectedItems) }
|
val items = blockedContacts.map { SelectableItem(it, it in selectedItems) }
|
||||||
|
|
||||||
val isEmpty get() = blockedContacts.isEmpty()
|
|
||||||
val unblockButtonEnabled get() = selectedItems.isNotEmpty()
|
val unblockButtonEnabled get() = selectedItems.isNotEmpty()
|
||||||
val emptyStateMessageTextViewVisible get() = blockedContacts.isEmpty()
|
val emptyStateMessageTextViewVisible get() = blockedContacts.isEmpty()
|
||||||
val nonEmptyStateGroupVisible get() = blockedContacts.isNotEmpty()
|
val nonEmptyStateGroupVisible get() = blockedContacts.isNotEmpty()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user