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

@ -87,7 +87,9 @@
<div class='send-message-area'>
<div class='message-composer'>
<input name='message' class='send-message' rows='6' type='textarea'>
<div class='attachments'> Add Files </div>
<div class='attachments'>
<input type='file' name='files[]' multiple class='file-input'>
</div>
<input type='submit'>
</div>
<div class='extension-details'>

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');
}