avoid unnessary muc mam queries when message count is 0 after subject

This commit is contained in:
Daniel Gultsch 2015-06-02 13:33:20 +02:00
parent ba5d0892a6
commit fe1cff016f
2 changed files with 7 additions and 1 deletions

View file

@ -249,6 +249,12 @@ public class Conversation extends AbstractEntity implements Blockable {
this.mLastReceivedOtrMessageId = id; this.mLastReceivedOtrMessageId = id;
} }
public int countMessages() {
synchronized (this.messages) {
return this.messages.size();
}
}
public interface OnMessageFound { public interface OnMessageFound {
public void onMessageFound(final Message message); public void onMessageFound(final Message message);

View file

@ -367,7 +367,7 @@ public class MessageParser extends AbstractParser implements
if (packet.hasChild("subject") && isTypeGroupChat) { if (packet.hasChild("subject") && isTypeGroupChat) {
Conversation conversation = mXmppConnectionService.find(account, from.toBareJid()); Conversation conversation = mXmppConnectionService.find(account, from.toBareJid());
if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) { if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
conversation.setHasMessagesLeftOnServer(true); conversation.setHasMessagesLeftOnServer(conversation.countMessages() > 0);
conversation.getMucOptions().setSubject(packet.findChildContent("subject")); conversation.getMucOptions().setSubject(packet.findChildContent("subject"));
mXmppConnectionService.updateConversationUi(); mXmppConnectionService.updateConversationUi();
return; return;