set catchup flag on mam only when doing that

This commit is contained in:
Daniel Gultsch 2017-05-04 22:11:46 +02:00
parent f98888d796
commit 404cf808b0
5 changed files with 16 additions and 14 deletions

View File

@ -67,7 +67,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
List<Conversation> conversations = mXmppConnectionService.getConversations(); List<Conversation> conversations = mXmppConnectionService.getConversations();
for (Conversation conversation : conversations) { for (Conversation conversation : conversations) {
if (conversation.getMode() == Conversation.MODE_SINGLE && conversation.getAccount() == account && startCatchup > conversation.getLastMessageTransmitted()) { if (conversation.getMode() == Conversation.MODE_SINGLE && conversation.getAccount() == account && startCatchup > conversation.getLastMessageTransmitted()) {
this.query(conversation,startCatchup); this.query(conversation,startCatchup,true);
} }
} }
query = new Query(account, startCatchup, endCatchup); query = new Query(account, startCatchup, endCatchup);
@ -83,11 +83,13 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
if (conversation.getLastMessageTransmitted() < 0 && conversation.countMessages() == 0) { if (conversation.getLastMessageTransmitted() < 0 && conversation.countMessages() == 0) {
query(conversation, query(conversation,
0, 0,
System.currentTimeMillis()); System.currentTimeMillis(),
true);
} else { } else {
query(conversation, query(conversation,
conversation.getLastMessageTransmitted(), conversation.getLastMessageTransmitted(),
System.currentTimeMillis()); System.currentTimeMillis(),
true);
} }
} }
@ -95,19 +97,21 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
if (conversation.getLastMessageTransmitted() < 0 && conversation.countMessages() == 0) { if (conversation.getLastMessageTransmitted() < 0 && conversation.countMessages() == 0) {
return query(conversation, return query(conversation,
0, 0,
System.currentTimeMillis()); System.currentTimeMillis(),
false);
} else { } else {
return query(conversation, return query(conversation,
conversation.getLastMessageTransmitted(), conversation.getLastMessageTransmitted(),
conversation.getAccount().getXmppConnection().getLastSessionEstablished()); conversation.getAccount().getXmppConnection().getLastSessionEstablished(),
false);
} }
} }
public Query query(final Conversation conversation, long end) { public Query query(final Conversation conversation, long end, boolean allowCatchup) {
return this.query(conversation,conversation.getLastMessageTransmitted(),end); return this.query(conversation,conversation.getLastMessageTransmitted(),end, allowCatchup);
} }
public Query query(Conversation conversation, long start, long end) { public Query query(Conversation conversation, long start, long end, boolean allowCatchup) {
synchronized (this.queries) { synchronized (this.queries) {
final Query query; final Query query;
final long startActual = Math.max(start,mXmppConnectionService.getAutomaticMessageDeletionDate()); final long startActual = Math.max(start,mXmppConnectionService.getAutomaticMessageDeletionDate());
@ -121,7 +125,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded {
this.queries.add(reverseCatchup); this.queries.add(reverseCatchup);
this.execute(reverseCatchup); this.execute(reverseCatchup);
} }
query = new Query(conversation, maxCatchup, end); query = new Query(conversation, maxCatchup, end, allowCatchup);
} }
if (start > end) { if (start > end) {
return null; return null;

View File

@ -246,7 +246,6 @@ public class NotificationService {
} }
public void updateNotification(final boolean notify) { public void updateNotification(final boolean notify) {
Log.d(Config.LOGTAG,"updateNotification("+Boolean.toString(notify)+")");
final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService);
final SharedPreferences preferences = mXmppConnectionService.getPreferences(); final SharedPreferences preferences = mXmppConnectionService.getPreferences();

View File

@ -1647,7 +1647,7 @@ public class XmppConnectionService extends Service {
&& conversation.getLastClearHistory() == 0) { && conversation.getLastClearHistory() == 0) {
if ((conversation.getMode() == Conversation.MODE_SINGLE && account.getXmppConnection().getFeatures().mam()) if ((conversation.getMode() == Conversation.MODE_SINGLE && account.getXmppConnection().getFeatures().mam())
|| (conversation.getMode() == Conversation.MODE_MULTI && conversation.getMucOptions().mamSupport())) { || (conversation.getMode() == Conversation.MODE_MULTI && conversation.getMucOptions().mamSupport())) {
MessageArchiveService.Query query = getMessageArchiveService().query(conversation, 0, timestamp); MessageArchiveService.Query query = getMessageArchiveService().query(conversation, 0, timestamp, false);
if (query != null) { if (query != null) {
query.setCallback(callback); query.setCallback(callback);
callback.informUser(R.string.fetching_history_from_server); callback.informUser(R.string.fetching_history_from_server);
@ -1761,7 +1761,7 @@ public class XmppConnectionService extends Service {
mMessageArchiveService.query(c); mMessageArchiveService.query(c);
} else { } else {
if (query.getConversation() == null) { if (query.getConversation() == null) {
mMessageArchiveService.query(c, query.getStart()); mMessageArchiveService.query(c, query.getStart(),query.isCatchup());
} }
} }
} }

View File

@ -35,7 +35,6 @@ import java.util.List;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus; import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession; import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;

View File

@ -570,7 +570,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
timestamp = System.currentTimeMillis(); timestamp = System.currentTimeMillis();
} }
conversation.messagesLoaded.set(true); conversation.messagesLoaded.set(true);
MessageArchiveService.Query query = activity.xmppConnectionService.getMessageArchiveService().query(conversation, 0, timestamp); MessageArchiveService.Query query = activity.xmppConnectionService.getMessageArchiveService().query(conversation, 0, timestamp, false);
if (query != null) { if (query != null) {
Toast.makeText(activity, R.string.fetching_history_from_server, Toast.LENGTH_LONG).show(); Toast.makeText(activity, R.string.fetching_history_from_server, Toast.LENGTH_LONG).show();
} else { } else {