From 3b84448d387d5c1cb34a0634bf4d7ecb08546ff8 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Thu, 27 Aug 2020 14:25:13 +1000 Subject: [PATCH] fix issues --- .../securesms/conversation/ConversationAdapter.java | 4 +++- src/org/thoughtcrime/securesms/database/MmsDatabase.java | 2 +- src/org/thoughtcrime/securesms/database/SmsDatabase.java | 2 +- .../thoughtcrime/securesms/database/model/MessageRecord.java | 3 +++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationAdapter.java b/src/org/thoughtcrime/securesms/conversation/ConversationAdapter.java index 0182fde11e..64e7365b1d 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationAdapter.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationAdapter.java @@ -426,7 +426,9 @@ public class ConversationAdapter @Override public void onBindHeaderViewHolder(HeaderViewHolder viewHolder, int position) { MessageRecord messageRecord = getRecordForPositionOrThrow(position); - viewHolder.setText(DateUtils.getRelativeDate(getContext(), locale, messageRecord.getDateReceived())); + long timestamp = messageRecord.getDateReceived(); + if (recipient.getAddress().isOpenGroup()) { timestamp = messageRecord.getTimestamp(); } + viewHolder.setText(DateUtils.getRelativeDate(getContext(), locale, timestamp)); } public void onBindLastSeenViewHolder(HeaderViewHolder viewHolder, int position) { diff --git a/src/org/thoughtcrime/securesms/database/MmsDatabase.java b/src/org/thoughtcrime/securesms/database/MmsDatabase.java index ba2c74da47..4ef30d33eb 100644 --- a/src/org/thoughtcrime/securesms/database/MmsDatabase.java +++ b/src/org/thoughtcrime/securesms/database/MmsDatabase.java @@ -844,7 +844,7 @@ public class MmsDatabase extends MessagingDatabase { // we use current time like a sortId of iOS as the receive time. // Since the messages has been sorted by server timestamp before they are processed, // the order here by actual receiving time should be correct. - long receiveTimestamp = System.currentTimeMillis(); + long receiveTimestamp = serverTimestamp; if (serverTimestamp == 0) { receiveTimestamp = retrieved.getSentTimeMillis(); } contentValues.put(DATE_RECEIVED, receiveTimestamp); // Loki - This is important due to how we handle GIFs contentValues.put(PART_COUNT, retrieved.getAttachments().size()); diff --git a/src/org/thoughtcrime/securesms/database/SmsDatabase.java b/src/org/thoughtcrime/securesms/database/SmsDatabase.java index d75b5346b1..aa9aeabdaf 100644 --- a/src/org/thoughtcrime/securesms/database/SmsDatabase.java +++ b/src/org/thoughtcrime/securesms/database/SmsDatabase.java @@ -629,7 +629,7 @@ public class SmsDatabase extends MessagingDatabase { // we use current time like a sortId of iOS as the receive time. // Since the messages has been sorted by server timestamp before they are processed, // the order here by actual receiving time should be correct. - long receiveTimestamp = System.currentTimeMillis(); + long receiveTimestamp = serverTimestamp; if (serverTimestamp == 0) { receiveTimestamp = message.getSentTimestampMillis(); } values.put(DATE_RECEIVED, receiveTimestamp); // Loki - This is important due to how we handle GIFs values.put(DATE_SENT, message.getSentTimestampMillis()); diff --git a/src/org/thoughtcrime/securesms/database/model/MessageRecord.java b/src/org/thoughtcrime/securesms/database/model/MessageRecord.java index 2e54b9d65e..effea38c60 100644 --- a/src/org/thoughtcrime/securesms/database/model/MessageRecord.java +++ b/src/org/thoughtcrime/securesms/database/model/MessageRecord.java @@ -139,6 +139,9 @@ public abstract class MessageRecord extends DisplayRecord { if (isPush() && getDateSent() < getDateReceived()) { return getDateSent(); } + if (getRecipient().getAddress().isOpenGroup()) { + return getDateSent(); + } return getDateReceived(); }