From 34718bcbbc2f0406607766e088d89ae2445999e5 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 24 Feb 2018 15:55:45 +0100 Subject: kill mam query when archiving conversation --- .../messenger/services/MessageArchiveService.java | 20 ++++++++++++++++++++ .../messenger/services/XmppConnectionService.java | 1 + 2 files changed, 21 insertions(+) (limited to 'src/main/java/de/pixart') diff --git a/src/main/java/de/pixart/messenger/services/MessageArchiveService.java b/src/main/java/de/pixart/messenger/services/MessageArchiveService.java index 8611bf873..f0d48a86f 100644 --- a/src/main/java/de/pixart/messenger/services/MessageArchiveService.java +++ b/src/main/java/de/pixart/messenger/services/MessageArchiveService.java @@ -300,6 +300,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/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index afa24f671..96c80c93d 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1978,6 +1978,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(); -- cgit v1.2.3