Some fixes around deleting/trashing messages
This commit is contained in:
parent
1e8b71e43b
commit
f4b6bcb8d9
@ -166,10 +166,11 @@ class MessageDetailFragment : Fragment() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.delete -> {
|
R.id.delete -> {
|
||||||
Singleton.labeler.delete(item)
|
|
||||||
if (isInTrash(item)) {
|
if (isInTrash(item)) {
|
||||||
|
Singleton.labeler.delete(item)
|
||||||
messageRepo.remove(item)
|
messageRepo.remove(item)
|
||||||
} else {
|
} else {
|
||||||
|
Singleton.labeler.delete(item)
|
||||||
messageRepo.save(item)
|
messageRepo.save(item)
|
||||||
}
|
}
|
||||||
activity.onBackPressed()
|
activity.onBackPressed()
|
||||||
|
@ -241,12 +241,16 @@ class MessageListFragment : Fragment(), ListHolder<Label> {
|
|||||||
this.swipeableMessageAdapter = adapter
|
this.swipeableMessageAdapter = adapter
|
||||||
|
|
||||||
Singleton.labeler.listener = { message, added, removed ->
|
Singleton.labeler.listener = { message, added, removed ->
|
||||||
if (added.contains(currentLabel)) {
|
if (currentLabel?.type == Label.Type.TRASH && added.all { it.type == Label.Type.TRASH } && removed.isEmpty()) {
|
||||||
// TODO: add to current list, at correct position
|
// 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)) {
|
} else if (removed.contains(currentLabel)) {
|
||||||
swipeableMessageAdapter?.remove(message)
|
swipeableMessageAdapter?.remove(message)
|
||||||
} else if (removed.any { it.type == Label.Type.UNREAD } || added.any { it.type == Label.Type.UNREAD }) {
|
} 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)
|
swipeableMessageAdapter?.update(message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user