Ensure recycle bin is ignored when disabled
This commit is contained in:
parent
cc6e9358f6
commit
bcb42d0ff5
|
@ -85,6 +85,7 @@ class MainActivity : SimpleActivity() {
|
|||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateMenuColors()
|
||||
refreshMenuItems()
|
||||
|
||||
getOrCreateConversationsAdapter().apply {
|
||||
if (storedTextColor != getProperTextColor()) {
|
||||
|
|
|
@ -312,10 +312,14 @@ class ThreadActivity : SimpleActivity() {
|
|||
ensureBackgroundThread {
|
||||
messages = try {
|
||||
if (isRecycleBin) {
|
||||
messagesDB.getThreadMessagesFromRecycleBin(threadId).toMutableList() as ArrayList<Message>
|
||||
messagesDB.getThreadMessagesFromRecycleBin(threadId)
|
||||
} else {
|
||||
messagesDB.getThreadMessages(threadId).toMutableList() as ArrayList<Message>
|
||||
}
|
||||
if (config.useRecycleBin) {
|
||||
messagesDB.getNonRecycledThreadMessages(threadId)
|
||||
} else {
|
||||
messagesDB.getThreadMessages(threadId)
|
||||
}
|
||||
}.toMutableList() as ArrayList<Message>
|
||||
} catch (e: Exception) {
|
||||
ArrayList()
|
||||
}
|
||||
|
@ -351,8 +355,11 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
val cachedMessagesCode = messages.clone().hashCode()
|
||||
if (!isRecycleBin) {
|
||||
val recycledMessages = messagesDB.getThreadMessagesFromRecycleBin(threadId).map { it.id }
|
||||
messages = getMessages(threadId, true).filter { !recycledMessages.contains(it.id) }.toMutableList() as ArrayList<Message>
|
||||
messages = getMessages(threadId, true)
|
||||
if (config.useRecycleBin) {
|
||||
val recycledMessages = messagesDB.getThreadMessagesFromRecycleBin(threadId).map { it.id }
|
||||
messages = messages.filter { !recycledMessages.contains(it.id) }.toMutableList() as ArrayList<Message>
|
||||
}
|
||||
}
|
||||
|
||||
val hasParticipantWithoutName = participants.any { contact ->
|
||||
|
@ -1543,8 +1550,10 @@ class ThreadActivity : SimpleActivity() {
|
|||
val scheduledMessages = messagesDB.getScheduledThreadMessages(threadId)
|
||||
.filterNot { it.isScheduled && it.millis() < System.currentTimeMillis() }
|
||||
addAll(scheduledMessages)
|
||||
val recycledMessages = messagesDB.getThreadMessagesFromRecycleBin(threadId).toSet()
|
||||
removeAll(recycledMessages)
|
||||
if (config.useRecycleBin) {
|
||||
val recycledMessages = messagesDB.getThreadMessagesFromRecycleBin(threadId).toSet()
|
||||
removeAll(recycledMessages)
|
||||
}
|
||||
}
|
||||
|
||||
messages.filter { !it.isScheduled && !it.isReceivedMessage() && it.id > lastMaxId }.forEach { latestMessage ->
|
||||
|
|
|
@ -27,9 +27,12 @@ interface MessagesDao {
|
|||
@Query("SELECT messages.* FROM messages LEFT OUTER JOIN recycle_bin_messages ON messages.id = recycle_bin_messages.id WHERE recycle_bin_messages.id IS NOT NULL AND recycle_bin_messages.deleted_ts < :timestamp")
|
||||
fun getOldRecycleBinMessages(timestamp: Long): List<Message>
|
||||
|
||||
@Query("SELECT messages.* FROM messages LEFT OUTER JOIN recycle_bin_messages ON messages.id = recycle_bin_messages.id WHERE recycle_bin_messages.id IS NULL AND thread_id = :threadId")
|
||||
@Query("SELECT * FROM messages WHERE thread_id = :threadId")
|
||||
fun getThreadMessages(threadId: Long): List<Message>
|
||||
|
||||
@Query("SELECT messages.* FROM messages LEFT OUTER JOIN recycle_bin_messages ON messages.id = recycle_bin_messages.id WHERE recycle_bin_messages.id IS NULL AND thread_id = :threadId")
|
||||
fun getNonRecycledThreadMessages(threadId: Long): List<Message>
|
||||
|
||||
@Query("SELECT messages.* FROM messages LEFT OUTER JOIN recycle_bin_messages ON messages.id = recycle_bin_messages.id WHERE recycle_bin_messages.id IS NOT NULL AND thread_id = :threadId")
|
||||
fun getThreadMessagesFromRecycleBin(threadId: Long): List<Message>
|
||||
|
||||
|
|
Loading…
Reference in New Issue