Some fixes around deleting/trashing messages

This commit is contained in:
Christian Basler 2017-09-15 15:25:32 +02:00
parent 1e8b71e43b
commit f4b6bcb8d9
2 changed files with 9 additions and 4 deletions

View File

@ -166,10 +166,11 @@ class MessageDetailFragment : Fragment() {
return true
}
R.id.delete -> {
Singleton.labeler.delete(item)
if (isInTrash(item)) {
Singleton.labeler.delete(item)
messageRepo.remove(item)
} else {
Singleton.labeler.delete(item)
messageRepo.save(item)
}
activity.onBackPressed()

View File

@ -241,12 +241,16 @@ class MessageListFragment : Fragment(), ListHolder<Label> {
this.swipeableMessageAdapter = adapter
Singleton.labeler.listener = { message, added, removed ->
if (added.contains(currentLabel)) {
// TODO: add to current list, at correct position
if (currentLabel?.type == Label.Type.TRASH && added.all { it.type == Label.Type.TRASH } && removed.isEmpty()) {
// work-around for messages that are deleted from trash
swipeableMessageAdapter?.remove(message)
} else if (added.contains(currentLabel)) {
// in most cases, top should be the correct position, but time will show if
// the message should be properly sorted in
swipeableMessageAdapter?.addFirst(message)
} else if (removed.contains(currentLabel)) {
swipeableMessageAdapter?.remove(message)
} else if (removed.any { it.type == Label.Type.UNREAD } || added.any { it.type == Label.Type.UNREAD }) {
// TODO: update if in current list, maybe update unread badges
swipeableMessageAdapter?.update(message)
}
}