mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Hide clear history action menu item when total count is zero.
This commit is contained in:
@@ -84,6 +84,7 @@ class CallLogFragment : Fragment(R.layout.call_log_fragment), CallLogAdapter.Cal
|
||||
val isFiltered = viewModel.filterSnapshot == CallLogFilter.MISSED
|
||||
menu.findItem(R.id.action_clear_missed_call_filter).isVisible = isFiltered
|
||||
menu.findItem(R.id.action_filter_missed_calls).isVisible = !isFiltered
|
||||
menu.findItem(R.id.action_clear_call_history).isVisible = !viewModel.isEmpty
|
||||
}
|
||||
|
||||
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||
|
||||
@@ -40,8 +40,12 @@ class CallLogViewModel(
|
||||
.stateFlowable
|
||||
.map { it.selectionState to it.stagedDeletion }
|
||||
|
||||
private val _isEmpty: BehaviorProcessor<Boolean> = BehaviorProcessor.createDefault(false)
|
||||
val isEmpty: Boolean get() = _isEmpty.value ?: false
|
||||
|
||||
val totalCount: Flowable<Int> = Flowable.combineLatest(distinctQueryFilterPairs, data) { a, _ -> a }
|
||||
.map { (query, filter) -> callLogRepository.getCallsCount(query, filter) }
|
||||
.doOnNext { _isEmpty.onNext(it <= 0) }
|
||||
|
||||
val selectionStateSnapshot: CallLogSelectionState
|
||||
get() = callLogStore.state.selectionState
|
||||
|
||||
Reference in New Issue
Block a user