aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-12-11 13:52:04 +0100
committerDaniel Gultsch <daniel@gultsch.de>2015-12-11 13:52:04 +0100
commit293e820a5857ffff5301babc43fc08120a35385c (patch)
tree0088453d3bb87a943904f0ad47f2afcc75f94256 /src/main/java/eu/siacs/conversations/entities
parent61b068110983c279fa31b9a1062b76dd6ae38416 (diff)
get rid of lastMessageTransmitted in favor of db query
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java30
1 files changed, 6 insertions, 24 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java
index e93d5564b..8b7aa8949 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -46,7 +46,6 @@ public class Conversation extends AbstractEntity implements Blockable {
public static final String ATTRIBUTE_NEXT_ENCRYPTION = "next_encryption";
public static final String ATTRIBUTE_MUC_PASSWORD = "muc_password";
public static final String ATTRIBUTE_MUTED_TILL = "muted_till";
- public static final String ATTRIBUTE_LAST_MESSAGE_TRANSMITTED = "last_message_transmitted";
private String name;
private String contactUuid;
@@ -693,33 +692,16 @@ public class Conversation extends AbstractEntity implements Blockable {
}
}
- public void resetLastMessageTransmitted() {
- this.setAttribute(ATTRIBUTE_LAST_MESSAGE_TRANSMITTED,String.valueOf(-1));
- }
-
- public boolean setLastMessageTransmitted(long value) {
- long before = getLastMessageTransmitted();
- if (value - before > 1000) {
- this.setAttribute(ATTRIBUTE_LAST_MESSAGE_TRANSMITTED, String.valueOf(value));
- return true;
- } else {
- return false;
- }
- }
-
public long getLastMessageTransmitted() {
- long timestamp = getLongAttribute(ATTRIBUTE_LAST_MESSAGE_TRANSMITTED,0);
- if (timestamp == 0) {
- synchronized (this.messages) {
- for(int i = this.messages.size() - 1; i >= 0; --i) {
- Message message = this.messages.get(i);
- if (message.getStatus() == Message.STATUS_RECEIVED) {
- return message.getTimeSent();
- }
+ synchronized (this.messages) {
+ for(int i = this.messages.size() - 1; i >= 0; --i) {
+ Message message = this.messages.get(i);
+ if (message.getStatus() == Message.STATUS_RECEIVED || message.isCarbon()) {
+ return message.getTimeSent();
}
}
}
- return timestamp;
+ return 0;
}
public void setMutedTill(long value) {