mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 10:35:19 +00:00
SES-2696 - Fix disappearing message
This commit is contained in:
parent
0fd801accb
commit
93af215d4e
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user