Fix call log multiselect deletions.

This commit is contained in:
Alex Hart
2023-04-25 16:42:33 -03:00
committed by GitHub
parent eb9915d445
commit 0e631508b2
7 changed files with 106 additions and 28 deletions

View File

@@ -51,10 +51,11 @@ class CallLogRepository : CallLogPagedDataSource.CallRepository {
}
fun deleteAllCallLogsExcept(
selectedCallRowIds: Set<Long>
selectedCallRowIds: Set<Long>,
missedOnly: Boolean
): Completable {
return Completable.fromAction {
SignalDatabase.calls.deleteAllCallEventsExcept(selectedCallRowIds)
SignalDatabase.calls.deleteAllCallEventsExcept(selectedCallRowIds, missedOnly)
}.observeOn(Schedulers.io())
}
}

View File

@@ -6,6 +6,7 @@ import androidx.annotation.MainThread
* Encapsulates a single deletion action
*/
class CallLogStagedDeletion(
private val filter: CallLogFilter,
private val stateSnapshot: CallLogSelectionState,
private val repository: CallLogRepository
) {
@@ -35,7 +36,7 @@ class CallLogStagedDeletion(
.toSet()
if (stateSnapshot.isExclusionary()) {
repository.deleteAllCallLogsExcept(callRowIds).subscribe()
repository.deleteAllCallLogsExcept(callRowIds, filter == CallLogFilter.MISSED).subscribe()
} else {
repository.deleteSelectedCallLogs(callRowIds).subscribe()
}

View File

@@ -101,6 +101,7 @@ class CallLogViewModel(
callLogStore.update {
it.copy(
stagedDeletion = CallLogStagedDeletion(
it.filter,
CallLogSelectionState.empty().toggle(call.id),
callLogRepository
)
@@ -114,6 +115,7 @@ class CallLogViewModel(
callLogStore.update {
it.copy(
stagedDeletion = CallLogStagedDeletion(
it.filter,
it.selectionState,
callLogRepository
)