call setToExpire when expire timer is started to set expire_at property of message

pull/1786/head
Brice-W 4 years ago
parent 18f15615d4
commit e5615357f7

@ -318,10 +318,6 @@ export class SessionMessagesList extends React.Component<Props, State> {
multiSelectMode: boolean,
message: MessageModel
) {
if (messageProps.expirationTimestamp != null && messageProps.expirationTimestamp < Date.now()) {
return;
}
const selected = !!messageProps?.id && this.props.selectedMessages.includes(messageProps.id);
messageProps.selected = selected;

@ -1058,6 +1058,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
if (this.get('expireTimer') && !this.get('expirationStartTimestamp')) {
const expirationStartTimestamp = Math.min(Date.now(), readAt || Date.now());
this.set({ expirationStartTimestamp });
this.setToExpire(false);
}
window.Whisper.Notifications.remove(
@ -1092,7 +1093,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
return msFromNow;
}
public async setToExpire(force = false) {
public async setToExpire(commit = true, force = false) {
if (this.isExpiring() && (force || !this.get('expires_at'))) {
const start = this.get('expirationStartTimestamp');
const delta = this.get('expireTimer') * 1000;
@ -1103,7 +1104,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
this.set({ expires_at: expiresAt });
const id = this.get('id');
if (id) {
if (id && commit) {
await this.commit();
}

Loading…
Cancel
Save