diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-04-18 19:58:40 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-04-18 19:58:40 +0200 |
commit | ee0264d98c9a348ea29d12796bed25f9ba1494fb (patch) | |
tree | cc559348547e504d37a6efa7826ea0120070babe /src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java | |
parent | d94eb9309b4ab3ee1dfd3cee637b47a52223e15b (diff) | |
parent | 7df96caedbbb96a28d4f7e07fa2d159c8ca1373f (diff) |
Merge branch 'master' into introduce_cplus_database_version
Conflicts:
gradle/wrapper/gradle-wrapper.properties
src/main/res/values/strings.xml
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java b/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java index f2298d8c..cd55b42f 100644 --- a/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java +++ b/src/main/java/de/thedevstack/conversationsplus/services/MessageArchiveService.java @@ -45,8 +45,10 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { } } } - long startCatchup = getLastMessageTransmitted(account); + Pair<Long,String> pair = mXmppConnectionService.databaseBackend.getLastMessageReceived(account); + long startCatchup = pair == null ? 0 : pair.first; long endCatchup = account.getXmppConnection().getLastSessionEstablished(); + final Query query; if (startCatchup == 0) { return; } else if (endCatchup - startCatchup >= Config.MAM_MAX_CATCHUP) { @@ -57,8 +59,11 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { this.query(conversation,startCatchup); } } + query = new Query(account, startCatchup, endCatchup); + } else { + query = new Query(account, startCatchup, endCatchup); + query.reference = pair.second; } - final Query query = new Query(account, startCatchup, endCatchup); this.queries.add(query); this.execute(query); } @@ -75,11 +80,6 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { } } - private long getLastMessageTransmitted(final Account account) { - Pair<Long,String> pair = mXmppConnectionService.databaseBackend.getLastMessageReceived(account); - return pair == null ? 0 : pair.first; - } - public Query query(final Conversation conversation) { if (conversation.getLastMessageTransmitted() < 0 && conversation.countMessages() == 0) { return query(conversation, @@ -292,7 +292,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { this.end = end; this.queryId = new BigInteger(50, mXmppConnectionService.getRNG()).toString(32); } - + private Query page(String reference) { Query query = new Query(this.account,this.start,this.end); query.reference = reference; |