Frontend for timer updates and timer indicator
This commit is contained in:
parent
448835e4d5
commit
2b2c6ab040
10 changed files with 242 additions and 26 deletions
|
@ -166,20 +166,26 @@
|
|||
}.bind(this));
|
||||
},
|
||||
|
||||
addExpirationTimerUpdate: function(source, time) {
|
||||
addExpirationTimerUpdate: function(time, source) {
|
||||
var now = Date.now();
|
||||
this.save({ expireTimer: time });
|
||||
var message = this.messageCollection.add({
|
||||
conversationId : this.id,
|
||||
type : 'expirationTimerUpdate',
|
||||
sent_at : now,
|
||||
received_at : now,
|
||||
timerUpdate : {
|
||||
conversationId : this.id,
|
||||
type : 'outgoing',
|
||||
sent_at : now,
|
||||
received_at : now,
|
||||
flags : textsecure.protobuf.DataMessage.Flags.EXPIRATION_TIMER_UPDATE,
|
||||
expirationTimerUpdate : {
|
||||
expireTimer : time,
|
||||
source : source
|
||||
}
|
||||
});
|
||||
message.save();
|
||||
},
|
||||
sendExpirationTimerUpdate: function(time) {
|
||||
this.addExpirationTimerUpdate(time, textsecure.storage.user.getNumber());
|
||||
// todo: send.
|
||||
},
|
||||
|
||||
isSearchable: function() {
|
||||
return !this.get('left') || !!this.get('lastMessage');
|
||||
|
|
|
@ -71,7 +71,6 @@
|
|||
if (this.isIncoming() && this.hasErrors()) {
|
||||
return i18n('incomingError');
|
||||
}
|
||||
|
||||
return this.get('body');
|
||||
},
|
||||
getNotificationText: function() {
|
||||
|
@ -126,15 +125,6 @@
|
|||
}
|
||||
return c;
|
||||
},
|
||||
getModelForExpirationTimerUpdate: function() {
|
||||
var id = this.get('timerUpdate').source;
|
||||
var c = ConversationController.get(id);
|
||||
if (!c) {
|
||||
c = ConversationController.create({ id: id, type: 'private' });
|
||||
c.fetch();
|
||||
}
|
||||
return c;
|
||||
},
|
||||
isOutgoing: function() {
|
||||
return this.get('type') === 'outgoing';
|
||||
},
|
||||
|
@ -364,9 +354,18 @@
|
|||
flags : dataMessage.flags,
|
||||
errors : []
|
||||
});
|
||||
|
||||
if (dataMessage.expireTimer) {
|
||||
if (message.isExpirationTimerUpdate()) {
|
||||
message.set({
|
||||
expirationTimerUpdate: {
|
||||
source : source,
|
||||
expireTimer : dataMessage.expireTimer
|
||||
}
|
||||
});
|
||||
conversation.set({expireTimer: dataMessage.expireTimer});
|
||||
} else if (dataMessage.expireTimer) {
|
||||
message.set({expireTimer: dataMessage.expireTimer});
|
||||
// todo: insert an update if needed
|
||||
conversation.set({expireTimer: dataMessage.expireTimer});
|
||||
}
|
||||
|
||||
var conversation_timestamp = conversation.get('timestamp');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue