mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 12:35:17 +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;
|
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
|
@Override
|
||||||
public CharSequence getDisplayBody(@NonNull Context context) {
|
public CharSequence getDisplayBody(@NonNull Context context) {
|
||||||
@ -144,22 +126,13 @@ public class ThreadRecord extends DisplayRecord {
|
|||||||
.put(NAME_KEY, getName())
|
.put(NAME_KEY, getName())
|
||||||
.format().toString();
|
.format().toString();
|
||||||
} else if (SmsDatabase.Types.isExpirationTimerUpdate(type)) {
|
} else if (SmsDatabase.Types.isExpirationTimerUpdate(type)) {
|
||||||
int seconds = (int) (getExpiresIn() / 1000);
|
// Use the same message as we would for displaying on the conversation screen.
|
||||||
if (seconds <= 0) {
|
// lastMessage shouldn't be null here, but we'll check just in case.
|
||||||
return Phrase.from(context, R.string.disappearingMessagesTurnedOff)
|
if (lastMessage != null) {
|
||||||
.put(NAME_KEY, getName())
|
return lastMessage.getDisplayBody(context).toString();
|
||||||
.format().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)) {
|
} else if (MmsSmsColumns.Types.isMediaSavedExtraction(type)) {
|
||||||
return Phrase.from(context, R.string.attachmentsMediaSaved)
|
return Phrase.from(context, R.string.attachmentsMediaSaved)
|
||||||
.put(NAME_KEY, getName())
|
.put(NAME_KEY, getName())
|
||||||
|
Loading…
Reference in New Issue
Block a user