kill pending queries when archiving conversation

This commit is contained in:
Daniel Gultsch 2021-03-16 10:22:52 +01:00
parent 3c60de54cb
commit 8764d11cce
1 changed files with 575 additions and 566 deletions

View File

@ -209,7 +209,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
}
void executePendingQueries(final Account account) {
List<Query> pending = new ArrayList<>();
final List<Query> pending = new ArrayList<>();
synchronized (this.pendingQueries) {
for (Iterator<Query> iterator = this.pendingQueries.iterator(); iterator.hasNext(); ) {
Query query = iterator.next();
@ -390,8 +390,17 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
}
}
void kill(Conversation conversation) {
void kill(final Conversation conversation) {
final ArrayList<Query> toBeKilled = new ArrayList<>();
synchronized (this.pendingQueries) {
for (final Iterator<Query> iterator = this.pendingQueries.iterator(); iterator.hasNext(); ) {
final Query query = iterator.next();
if (query.getConversation() == conversation) {
iterator.remove();
Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": killed pending MAM query for archived conversation");
}
}
}
synchronized (this.queries) {
for (final Query q : queries) {
if (q.conversation == conversation) {
@ -399,7 +408,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
}
}
}
for (Query q : toBeKilled) {
for (final Query q : toBeKilled) {
kill(q);
}
}