diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-06-13 19:06:09 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-06-14 21:28:29 +0200 |
commit | 38dd084e33ea25433abc4894f46ebdded152d64c (patch) | |
tree | 54e53efb1a4415c95d8dbef9c295c2dca57abd43 /src/main/java/eu/siacs/conversations/entities | |
parent | aaeced4e209812f3a779dc9560105dc8d3218af5 (diff) |
remove messages from decryption queue when trimming a conversation
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Conversation.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java index ca5845f56..8cff7b959 100644 --- a/src/main/java/eu/siacs/conversations/entities/Conversation.java +++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java @@ -22,6 +22,7 @@ import java.util.Iterator; import java.util.List; import eu.siacs.conversations.Config; +import eu.siacs.conversations.crypto.PgpDecryptionService; import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.jid.InvalidJidException; @@ -206,7 +207,13 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl final int size = messages.size(); final int maxsize = Config.PAGE_SIZE * Config.MAX_NUM_PAGES; if (size > maxsize) { - this.messages.subList(0, size - maxsize).clear(); + List<Message> discards = this.messages.subList(0, size - maxsize); + final PgpDecryptionService pgpDecryptionService = account.getPgpDecryptionService(); + if (pgpDecryptionService != null) { + pgpDecryptionService.discard(discards); + } + discards.clear(); + untieMessages(); } } } @@ -963,9 +970,13 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } } }); - for(Message message : this.messages) { - message.untie(); - } + untieMessages(); + } + } + + private void untieMessages() { + for(Message message : this.messages) { + message.untie(); } } |