Allow re-send of messages in msg detail view on OutgoingKeyError
We also show more errors than we used to in the MessageDetail screen to help make it clear what is happening, and why the user would need to re-send. FREEBIE
This commit is contained in:
parent
47c5142a83
commit
a827334c3e
6 changed files with 82 additions and 23 deletions
|
@ -10,8 +10,7 @@
|
|||
templateName: 'contact-detail',
|
||||
initialize: function(options) {
|
||||
this.errors = _.reject(options.errors, function(e) {
|
||||
return (e.name === 'IncomingIdentityKeyError' ||
|
||||
e.name === 'OutgoingIdentityKeyError' ||
|
||||
return (e.name === 'OutgoingIdentityKeyError' ||
|
||||
e.name === 'OutgoingMessageError' ||
|
||||
e.name === 'SendMessageNetworkError');
|
||||
});
|
||||
|
@ -36,6 +35,33 @@
|
|||
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
},
|
||||
events: {
|
||||
'click button.retry': 'onRetry'
|
||||
},
|
||||
onRetry: function(e) {
|
||||
var number = _.find(e.target.attributes, function(attribute) {
|
||||
return attribute.name === 'data-number';
|
||||
});
|
||||
if (number) {
|
||||
this.model.resend(number.value);
|
||||
}
|
||||
},
|
||||
getContact: function(number) {
|
||||
var c = ConversationController.get(number);
|
||||
return {
|
||||
number: number,
|
||||
title: c ? c.getTitle() : number
|
||||
};
|
||||
},
|
||||
buildRetryTargetList: function() {
|
||||
var targets = _.filter(this.model.get('errors'), function(e) {
|
||||
return e.number && e.name === 'OutgoingIdentityKeyError';
|
||||
});
|
||||
|
||||
return _.map(targets, function(e) {
|
||||
return this.getContact(e.number);
|
||||
}.bind(this));
|
||||
},
|
||||
contacts: function() {
|
||||
if (this.model.isIncoming()) {
|
||||
var number = this.model.get('source');
|
||||
|
@ -45,35 +71,36 @@
|
|||
}
|
||||
},
|
||||
renderContact: function(contact) {
|
||||
var grouped = _.groupBy(this.model.get('errors'), 'number');
|
||||
|
||||
var view = new ContactView({
|
||||
model: contact,
|
||||
errors: this.errors[contact.id]
|
||||
errors: grouped[contact.id]
|
||||
}).render();
|
||||
this.$('.contacts').append(view.el);
|
||||
},
|
||||
render: function() {
|
||||
this.errors = _.groupBy(this.model.get('errors'), 'number');
|
||||
var unknownErrors = this.errors['undefined'];
|
||||
if (unknownErrors) {
|
||||
unknownErrors = unknownErrors.filter(function(e) {
|
||||
return (e.name !== 'MessageError');
|
||||
});
|
||||
}
|
||||
var retryTargets = this.buildRetryTargetList();
|
||||
var allowRetry = retryTargets.length > 0;
|
||||
|
||||
this.$el.html(Mustache.render(_.result(this, 'template', ''), {
|
||||
sent_at : moment(this.model.get('sent_at')).format('LLLL'),
|
||||
received_at : this.model.isIncoming() ? moment(this.model.get('received_at')).format('LLLL') : null,
|
||||
tofrom : this.model.isIncoming() ? i18n('from') : i18n('to'),
|
||||
errors : unknownErrors,
|
||||
title : i18n('messageDetail'),
|
||||
sent : i18n('sent'),
|
||||
received : i18n('received'),
|
||||
errorLabel : i18n('error')
|
||||
sent_at : moment(this.model.get('sent_at')).format('LLLL'),
|
||||
received_at : this.model.isIncoming() ? moment(this.model.get('received_at')).format('LLLL') : null,
|
||||
tofrom : this.model.isIncoming() ? i18n('from') : i18n('to'),
|
||||
errors : this.model.get('errors'),
|
||||
allowRetry : allowRetry,
|
||||
retryTargets : retryTargets,
|
||||
title : i18n('messageDetail'),
|
||||
sent : i18n('sent'),
|
||||
received : i18n('received'),
|
||||
errorLabel : i18n('error'),
|
||||
retryDescription: i18n('retryDescription')
|
||||
}));
|
||||
this.view.$el.prependTo(this.$('.message-container'));
|
||||
|
||||
if (this.model.isOutgoing()) {
|
||||
this.conversation.contactCollection.reject(function(c) {
|
||||
return c.id === textsecure.storage.user.getNumber();
|
||||
return c.isMe();
|
||||
}).forEach(this.renderContact.bind(this));
|
||||
} else {
|
||||
this.renderContact(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue