remove messages from decryption queue when trimming a conversation

This commit is contained in:
Daniel Gultsch 2016-06-13 19:06:09 +02:00
parent 40f81f19df
commit 39ad426ca9
2 changed files with 19 additions and 4 deletions

View File

@ -50,6 +50,10 @@ public class PgpDecryptionService {
continueDecryption(); continueDecryption();
} }
public synchronized void discard(List<Message> discards) {
this.messages.removeAll(discards);
}
protected synchronized void decryptNext() { protected synchronized void decryptNext() {
if (pendingIntent == null if (pendingIntent == null
&& getOpenPgpApi() != null && getOpenPgpApi() != null

View File

@ -22,6 +22,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
import eu.siacs.conversations.crypto.PgpDecryptionService;
import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.xmpp.chatstate.ChatState; import eu.siacs.conversations.xmpp.chatstate.ChatState;
import eu.siacs.conversations.xmpp.jid.InvalidJidException; 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 size = messages.size();
final int maxsize = Config.PAGE_SIZE * Config.MAX_NUM_PAGES; final int maxsize = Config.PAGE_SIZE * Config.MAX_NUM_PAGES;
if (size > maxsize) { 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();
} }
} }
} }
@ -949,9 +956,13 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
} }
} }
}); });
for(Message message : this.messages) { untieMessages();
message.untie(); }
} }
private void untieMessages() {
for(Message message : this.messages) {
message.untie();
} }
} }