From 03fa58634bed54bf8bf1429ee1923fb474b17b51 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 24 Feb 2018 09:39:17 +0100 Subject: [PATCH] kill mam query when archiving conversation --- .../services/MessageArchiveService.java | 20 +++++++++++++++++++ .../services/XmppConnectionService.java | 1 + 2 files changed, 21 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java index 8f807463f..d075c0164 100644 --- a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java +++ b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java @@ -301,6 +301,26 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { } } + public void kill(Conversation conversation) { + synchronized (this.queries) { + for (Query q : queries) { + if (q.conversation == conversation) { + kill(q); + } + } + } + } + + private void kill(Query query) { + Log.d(Config.LOGTAG,query.getAccount().getJid().toBareJid()+": killing mam query prematurely"); + query.callback = null; + this.finalizeQuery(query,false); + if (query.isCatchup() && query.getActualMessageCount() > 0) { + mXmppConnectionService.getNotificationService().finishBacklog(true,query.getAccount()); + } + this.processPostponed(query); + } + private void processPostponed(Query query) { query.account.getAxolotlService().processPostponed(); Log.d(Config.LOGTAG,query.getAccount().getJid().toBareJid()+": found "+query.pendingReceiptRequests.size()+" pending receipt requests"); diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 85549c97a..2e9e1c366 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1794,6 +1794,7 @@ public class XmppConnectionService extends Service { getNotificationService().clear(conversation); conversation.setStatus(Conversation.STATUS_ARCHIVED); synchronized (this.conversations) { + getMessageArchiveService().kill(conversation); if (conversation.getMode() == Conversation.MODE_MULTI) { if (conversation.getAccount().getStatus() == Account.State.ONLINE) { Bookmark bookmark = conversation.getBookmark();