From 93af215d4e3b3dd5b5172059140a87b49f9059a2 Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:44:30 +1000 Subject: [PATCH] SES-2696 - Fix disappearing message --- .../database/model/ThreadRecord.java | 39 +++---------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/model/ThreadRecord.java b/app/src/main/java/org/thoughtcrime/securesms/database/model/ThreadRecord.java index 61dc29c396..d91f4c428c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/model/ThreadRecord.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/model/ThreadRecord.java @@ -99,24 +99,6 @@ public class ThreadRecord extends DisplayRecord { return name; } - private String getDisappearingMsgExpiryTypeString(Context context) { - MessageRecord lm = this.lastMessage; - if (lm == null) { - Log.w("ThreadRecord", "Could not get last message to determine disappearing msg type."); - return "Unknown"; - } - long expireStarted = lm.getExpireStarted(); - - // Note: This works because expireStarted is 0 for messages which are 'Disappear after read' - // while it's a touch higher than the sent timestamp for "Disappear after send". We could then - // use `expireStarted == 0`, but that's not how it's done in UpdateMessageBuilder so to keep - // things the same I'll assume there's a reason for this and follow suit. - // Also: `this.lastMessage.getExpiresIn()` is available. - if (expireStarted >= dateSent) { - return context.getString(R.string.disappearingMessagesSent); - } - return context.getString(R.string.read); - } @Override public CharSequence getDisplayBody(@NonNull Context context) { @@ -144,22 +126,13 @@ public class ThreadRecord extends DisplayRecord { .put(NAME_KEY, getName()) .format().toString(); } else if (SmsDatabase.Types.isExpirationTimerUpdate(type)) { - int seconds = (int) (getExpiresIn() / 1000); - if (seconds <= 0) { - return Phrase.from(context, R.string.disappearingMessagesTurnedOff) - .put(NAME_KEY, getName()) - .format().toString(); + // Use the same message as we would for displaying on the conversation screen. + // lastMessage shouldn't be null here, but we'll check just in case. + if (lastMessage != null) { + return lastMessage.getDisplayBody(context).toString(); + } else { + return ""; } - - // Implied that disappearing messages is enabled.. - String time = ExpirationUtil.getExpirationDisplayValue(context, seconds); - String disappearAfterWhat = getDisappearingMsgExpiryTypeString(context); // Disappear after send or read? - return Phrase.from(context, R.string.disappearingMessagesSet) - .put(NAME_KEY, getName()) - .put(TIME_KEY, time) - .put(DISAPPEARING_MESSAGES_TYPE_KEY, disappearAfterWhat) - .format().toString(); - } else if (MmsSmsColumns.Types.isMediaSavedExtraction(type)) { return Phrase.from(context, R.string.attachmentsMediaSaved) .put(NAME_KEY, getName())