Skip to content

Commit

Permalink
Ensure timer updates show in convo before initiating message
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal committed Jun 14, 2018
1 parent fae282c commit b0cfb5a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 7 additions & 2 deletions js/models/conversations.js
Expand Up @@ -618,11 +618,16 @@
updateExpirationTimer: function(expireTimer, source, received_at) {
if (!expireTimer) { expireTimer = null; }
source = source || textsecure.storage.user.getNumber();
var timestamp = received_at || Date.now();
// When we add a disappearing messages notification to the conversation, we want it
// to be above the message that initiated that change, hence the subtraction.
var timestamp = (received_at || Date.now()) - 1;
this.save({ expireTimer: expireTimer });
var message = this.messageCollection.add({
// Even though this isn't reflected to the user, we want to place the last seen
// indicator above it. We set it to 'unread' to trigger that placement.
unread : 1,
conversationId : this.id,
type : received_at ? 'incoming' : 'outgoing',
// No type; 'incoming' messages are specially treated by conversation.markRead()
sent_at : timestamp,
received_at : timestamp,
flags : textsecure.protobuf.DataMessage.Flags.EXPIRATION_TIMER_UPDATE,
Expand Down
8 changes: 8 additions & 0 deletions js/views/message_view.js
Expand Up @@ -78,6 +78,7 @@
this.conversation = this.model.getExpirationTimerUpdateSource();
this.listenTo(this.conversation, 'change', this.render);
this.listenTo(this.model, 'unload', this.remove);
this.listenTo(this.model, 'change', this.onChange);
},
render_attributes: function() {
var seconds = this.model.get('expirationTimerUpdate').expireTimer;
Expand All @@ -91,6 +92,13 @@
Whisper.ExpirationTimerOptions.getName(seconds)]);
}
return { content: timerMessage };
},
onChange: function() {
this.addId();
},
addId: function() {
// This is important to enable the lastSeenIndicator when it's just been added.
this.$el.attr('id', this.id());
}
});

Expand Down

0 comments on commit b0cfb5a

Please sign in to comment.