aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2015-03-01 12:05:54 +0100
committeriNPUTmice <daniel@gultsch.de>2015-03-01 12:05:54 +0100
commitd318af098d28b6685219f852558087eee5c8c3ae (patch)
treed01867705d7de5b573bc29be0bb54b37d8f788cd /src/main/java/eu/siacs/conversations/entities
parent4beb954da5652915dbb0ffb3839d517bfd719b24 (diff)
merge messages with related status (unsend, send, send_received)
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Message.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java
index ccf274b7..7ad43d53 100644
--- a/src/main/java/eu/siacs/conversations/entities/Message.java
+++ b/src/main/java/eu/siacs/conversations/entities/Message.java
@@ -362,7 +362,8 @@ public class Message extends AbstractEntity {
message.getDownloadable() == null &&
message.getEncryption() != Message.ENCRYPTION_PGP &&
this.getType() == message.getType() &&
- this.getStatus() == message.getStatus() &&
+ //this.getStatus() == message.getStatus() &&
+ isStatusMergeable(this.getStatus(),message.getStatus()) &&
this.getEncryption() == message.getEncryption() &&
this.getCounterpart() != null &&
this.getCounterpart().equals(message.getCounterpart()) &&
@@ -374,6 +375,17 @@ public class Message extends AbstractEntity {
);
}
+ private static boolean isStatusMergeable(int a, int b) {
+ return a == b || (
+ ( a == Message.STATUS_SEND_RECEIVED && b == Message.STATUS_UNSEND)
+ || (a == Message.STATUS_SEND_RECEIVED && b == Message.STATUS_SEND)
+ || (a == Message.STATUS_UNSEND && b == Message.STATUS_SEND)
+ || (a == Message.STATUS_UNSEND && b == Message.STATUS_SEND_RECEIVED)
+ || (a == Message.STATUS_SEND && b == Message.STATUS_UNSEND)
+ || (a == Message.STATUS_SEND && b == Message.STATUS_SEND_RECEIVED)
+ );
+ }
+
public String getMergedBody() {
final Message next = this.next();
if (this.mergeable(next)) {
@@ -387,6 +399,10 @@ public class Message extends AbstractEntity {
}
public int getMergedStatus() {
+ final Message next = this.next();
+ if (this.mergeable(next)) {
+ return next.getStatus();
+ }
return getStatus();
}