prepend instead off append mam messages to conversations when going in reverse

This commit is contained in:
Daniel Gultsch 2016-02-04 16:40:18 +01:00
parent 28733e052f
commit 91ec4839ac
2 changed files with 13 additions and 2 deletions

View File

@ -752,7 +752,7 @@ public class Conversation extends AbstractEntity implements Blockable {
} }
public boolean alwaysNotify() { public boolean alwaysNotify() {
return mode == MODE_SINGLE || getBooleanAttribute(ATTRIBUTE_ALWAYS_NOTIFY,Config.ALWAYS_NOTIFY_BY_DEFAULT || isPnNA()); return mode == MODE_SINGLE || getBooleanAttribute(ATTRIBUTE_ALWAYS_NOTIFY, Config.ALWAYS_NOTIFY_BY_DEFAULT || isPnNA());
} }
public boolean setAttribute(String key, String value) { public boolean setAttribute(String key, String value) {
@ -814,6 +814,13 @@ public class Conversation extends AbstractEntity implements Blockable {
} }
} }
public void prepend(Message message) {
message.setConversation(this);
synchronized (this.messages) {
this.messages.add(0,message);
}
}
public void addAll(int index, List<Message> messages) { public void addAll(int index, List<Message> messages) {
synchronized (this.messages) { synchronized (this.messages) {
this.messages.addAll(index, messages); this.messages.addAll(index, messages);

View File

@ -398,7 +398,11 @@ public class MessageParser extends AbstractParser implements
return; return;
} }
if (query != null && query.getPagingOrder() == MessageArchiveService.PagingOrder.REVERSE) {
conversation.prepend(message);
} else {
conversation.add(message); conversation.add(message);
}
if (query == null || query.getWith() == null) { //either no mam or catchup if (query == null || query.getWith() == null) { //either no mam or catchup
if (status == Message.STATUS_SEND || status == Message.STATUS_SEND_RECEIVED) { if (status == Message.STATUS_SEND || status == Message.STATUS_SEND_RECEIVED) {