mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 03:32:15 -05:00
properly clean up timed out mam queries
This commit is contained in:
parent
ede92235d7
commit
2262921ff4
@ -425,7 +425,7 @@ public class MessageParser extends AbstractParser implements
|
|||||||
mXmppConnectionService.sendMessagePacket(account, receipt);
|
mXmppConnectionService.sendMessagePacket(account, receipt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (account.getXmppConnection() != null && account.getXmppConnection().getFeatures().advancedStreamFeaturesLoaded()) {
|
if (account.isOnlineAndConnected() && query == null) {
|
||||||
if (conversation.setLastMessageTransmitted(System.currentTimeMillis())) {
|
if (conversation.setLastMessageTransmitted(System.currentTimeMillis())) {
|
||||||
mXmppConnectionService.updateConversation(conversation);
|
mXmppConnectionService.updateConversation(conversation);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,15 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||||||
this.mXmppConnectionService = service;
|
this.mXmppConnectionService = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void catchup(final Account account) {
|
private void catchup(final Account account) {
|
||||||
|
synchronized (this.queries) {
|
||||||
|
for(Iterator<Query> iterator = this.queries.iterator(); iterator.hasNext();) {
|
||||||
|
Query query = iterator.next();
|
||||||
|
if (query.getAccount() == account) {
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
long startCatchup = getLastMessageTransmitted(account);
|
long startCatchup = getLastMessageTransmitted(account);
|
||||||
long endCatchup = account.getXmppConnection().getLastSessionEstablished();
|
long endCatchup = account.getXmppConnection().getLastSessionEstablished();
|
||||||
if (startCatchup == 0) {
|
if (startCatchup == 0) {
|
||||||
@ -131,7 +139,14 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
|
|||||||
this.mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {
|
this.mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
if (packet.getType() != IqPacket.TYPE.RESULT) {
|
if (packet.getType() == IqPacket.TYPE.TIMEOUT) {
|
||||||
|
synchronized (MessageArchiveService.this.queries) {
|
||||||
|
MessageArchiveService.this.queries.remove(query);
|
||||||
|
if (query.hasCallback()) {
|
||||||
|
query.callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (packet.getType() != IqPacket.TYPE.RESULT) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": error executing mam: " + packet.toString());
|
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": error executing mam: " + packet.toString());
|
||||||
finalizeQuery(query);
|
finalizeQuery(query);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user