Add attachment inputs to new conversation form

Fixes reference error to 'map' on undefined attachments list.
This commit is contained in:
lilia 2014-11-03 17:51:49 -08:00
parent f7d92ccb5b
commit aa937ae1d1
2 changed files with 11 additions and 2 deletions

View file

@ -40,6 +40,7 @@ var Whisper = Whisper || {};
Mustache.parse(this.template);
this.render();
this.input = new MessageRecipientInputView({el: this.$el.find('input.number')});
this.fileInput = new Whisper.FileInputView({el: this.$el.find('.attachments')});
},
events: {
@ -53,7 +54,13 @@ var Whisper = Whisper || {};
if (number) {
var thread = Whisper.Threads.findOrCreateForRecipient(number);
var message_input = this.$el.find('input.send-message');
thread.sendMessage(message_input.val());
var message = message_input.val();
if (message.length > 0 || this.fileInput.hasFiles()) {
this.fileInput.getFiles().then(function(attachments) {
thread.sendMessage(message, attachments);
});
message_input.val("");
}
this.remove();
thread.trigger('render');
}