mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Fixed conversation deletion
This commit is contained in:
@@ -93,7 +93,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
override val dismissRatingIntent by lazy { rateDismiss.clicks() }
|
||||
override val rateIntent by lazy { rateOkay.clicks() }
|
||||
override val conversationsSelectedIntent by lazy { conversationsAdapter.selectionChanges }
|
||||
override val confirmDeleteIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val confirmDeleteIntent: Subject<List<Long>> = PublishSubject.create()
|
||||
override val swipeConversationIntent by lazy { itemTouchCallback.swipes }
|
||||
override val undoArchiveIntent: Subject<Unit> = PublishSubject.create()
|
||||
override val snackbarButtonIntent by lazy { snackbarButton.clicks() }
|
||||
@@ -284,11 +284,12 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
conversationsAdapter.clearSelection()
|
||||
}
|
||||
|
||||
override fun showDeleteDialog(count: Int) {
|
||||
override fun showDeleteDialog(conversations: List<Long>) {
|
||||
val count = conversations.size
|
||||
AlertDialog.Builder(this)
|
||||
.setTitle(R.string.dialog_delete_title)
|
||||
.setMessage(resources.getQuantityString(R.plurals.dialog_delete_message, count, count))
|
||||
.setPositiveButton(R.string.button_delete) { _, _ -> confirmDeleteIntent.onNext(Unit) }
|
||||
.setPositiveButton(R.string.button_delete) { _, _ -> confirmDeleteIntent.onNext(conversations) }
|
||||
.setNegativeButton(R.string.button_cancel, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ interface MainView : QkView<MainState> {
|
||||
val dismissRatingIntent: Observable<*>
|
||||
val rateIntent: Observable<*>
|
||||
val conversationsSelectedIntent: Observable<List<Long>>
|
||||
val confirmDeleteIntent: Observable<Unit>
|
||||
val confirmDeleteIntent: Observable<List<Long>>
|
||||
val swipeConversationIntent: Observable<Pair<Long, Int>>
|
||||
val undoArchiveIntent: Observable<Unit>
|
||||
val snackbarButtonIntent: Observable<Unit>
|
||||
@@ -43,7 +43,7 @@ interface MainView : QkView<MainState> {
|
||||
fun requestPermissions()
|
||||
fun clearSearch()
|
||||
fun clearSelection()
|
||||
fun showDeleteDialog(count: Int)
|
||||
fun showDeleteDialog(conversations: List<Long>)
|
||||
fun showArchivedSnackbar()
|
||||
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ class MainViewModel @Inject constructor(
|
||||
view.clearSelection()
|
||||
}
|
||||
|
||||
R.id.delete -> view.showDeleteDialog(conversations.size)
|
||||
R.id.delete -> view.showDeleteDialog(conversations)
|
||||
|
||||
R.id.pin -> {
|
||||
markPinned.execute(conversations)
|
||||
@@ -299,10 +299,6 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
// Delete the conversation
|
||||
view.confirmDeleteIntent
|
||||
.withLatestFrom(view.conversationsSelectedIntent, view.swipeConversationIntent) { _, conversations, swipe ->
|
||||
// If conversations are selected, use those. Otherwise, this was triggered by a swipe-to-delete
|
||||
conversations.takeIf { it.isNotEmpty() } ?: listOf(swipe.first)
|
||||
}
|
||||
.autoDisposable(view.scope())
|
||||
.subscribe { conversations ->
|
||||
deleteConversations.execute(conversations)
|
||||
@@ -315,7 +311,7 @@ class MainViewModel @Inject constructor(
|
||||
val action = if (direction == ItemTouchHelper.RIGHT) prefs.swipeRight.get() else prefs.swipeLeft.get()
|
||||
when (action) {
|
||||
Preferences.SWIPE_ACTION_ARCHIVE -> markArchived.execute(listOf(threadId)) { view.showArchivedSnackbar() }
|
||||
Preferences.SWIPE_ACTION_DELETE -> view.showDeleteDialog(1)
|
||||
Preferences.SWIPE_ACTION_DELETE -> view.showDeleteDialog(listOf(threadId))
|
||||
Preferences.SWIPE_ACTION_CALL -> conversationRepo.getConversation(threadId)?.recipients?.firstOrNull()?.address?.let(navigator::makePhoneCall)
|
||||
Preferences.SWIPE_ACTION_READ -> markRead.execute(listOf(threadId))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user