Preserve disabled state in the middle of sending message (#1937)

* Preserve disabled state in send-message field on click

Also: get consistent in treatment of 'disabled' property.

* Add some comments explaining how audio recording dismissal works
pull/749/head
Scott Nonnenberg 7 years ago committed by GitHub
parent 98d3a5e607
commit e999473f19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -393,6 +393,9 @@
captureAudio: function(e) { captureAudio: function(e) {
e.preventDefault(); e.preventDefault();
// Note - clicking anywhere will close the audio capture panel, due to
// the onClick handler in InboxView, which calls its closeRecording method.
if (this.captureAudioView) { if (this.captureAudioView) {
this.captureAudioView.remove(); this.captureAudioView.remove();
this.captureAudioView = null; this.captureAudioView = null;
@ -404,7 +407,7 @@
view.on('closed', this.endCaptureAudio.bind(this)); view.on('closed', this.endCaptureAudio.bind(this));
view.$el.appendTo(this.$('.capture-audio')); view.$el.appendTo(this.$('.capture-audio'));
this.$('.send-message').attr('disabled','disabled'); this.$('.send-message').attr('disabled', true);
this.$('.microphone').hide(); this.$('.microphone').hide();
}, },
handleAudioCapture: function(blob) { handleAudioCapture: function(blob) {
@ -584,7 +587,11 @@
}, },
focusMessageField: function() { focusMessageField: function() {
this.$messageField.prop('disabled', false); this.$messageField.focus();
},
focusMessageFieldAndClearDisabled: function() {
this.$messageField.removeAttr('disabled');
this.$messageField.focus(); this.$messageField.focus();
}, },
@ -888,7 +895,7 @@
this.checkUnverifiedSendMessage(e, {force: true}); this.checkUnverifiedSendMessage(e, {force: true});
}.bind(this), }.bind(this),
reject: function() { reject: function() {
this.focusMessageField(); this.focusMessageFieldAndClearDisabled();
}.bind(this) }.bind(this)
}); });
@ -899,7 +906,7 @@
checkUnverifiedSendMessage: function(e, options) { checkUnverifiedSendMessage: function(e, options) {
e.preventDefault(); e.preventDefault();
this.sendStart = Date.now(); this.sendStart = Date.now();
this.$messageField.prop('disabled', true); this.$messageField.attr('disabled', true);
options = options || {}; options = options || {};
_.defaults(options, {force: false}); _.defaults(options, {force: false});
@ -920,7 +927,7 @@
this.showSendConfirmationDialog(e, contacts); this.showSendConfirmationDialog(e, contacts);
}.bind(this)).catch(function(error) { }.bind(this)).catch(function(error) {
this.focusMessageField(); this.focusMessageFieldAndClearDisabled();
console.log( console.log(
'checkUnverifiedSendMessage error:', 'checkUnverifiedSendMessage error:',
error && error.stack ? error.stack : error error && error.stack ? error.stack : error
@ -945,7 +952,7 @@
this.showSendConfirmationDialog(e, contacts); this.showSendConfirmationDialog(e, contacts);
}.bind(this)).catch(function(error) { }.bind(this)).catch(function(error) {
this.focusMessageField(); this.focusMessageFieldAndClearDisabled();
console.log( console.log(
'checkUntrustedSendMessage error:', 'checkUntrustedSendMessage error:',
error && error.stack ? error.stack : error error && error.stack ? error.stack : error
@ -1008,7 +1015,7 @@
if (toast) { if (toast) {
toast.$el.insertAfter(this.$el); toast.$el.insertAfter(this.$el);
toast.render(); toast.render();
this.focusMessageField(); this.focusMessageFieldAndClearDisabled();
return; return;
} }
@ -1021,15 +1028,15 @@
console.log('Send pre-checks took', sendDelta, 'milliseconds'); console.log('Send pre-checks took', sendDelta, 'milliseconds');
this.model.sendMessage(message, attachments); this.model.sendMessage(message, attachments);
input.val(""); input.val("");
this.focusMessageField(); this.focusMessageFieldAndClearDisabled();
this.forceUpdateMessageFieldSize(e); this.forceUpdateMessageFieldSize(e);
this.fileInput.deleteFiles(); this.fileInput.deleteFiles();
}.bind(this)).catch(function() { }.bind(this)).catch(function() {
console.log('Error pulling attached files before send'); console.log('Error pulling attached files before send');
this.focusMessageField(); this.focusMessageFieldAndClearDisabled();
}.bind(this)); }.bind(this));
} else { } else {
this.focusMessageField(); this.focusMessageFieldAndClearDisabled();
} }
}, },

@ -28,6 +28,9 @@
this.$('.time').text(minutes + ':' + seconds); this.$('.time').text(minutes + ':' + seconds);
}, },
close: function() { close: function() {
// Note: the 'close' event can be triggered by InboxView, when the user clicks
// anywhere outside the recording pane.
if (this.recorder.isRecording()) { if (this.recorder.isRecording()) {
this.recorder.cancelRecording(); this.recorder.cancelRecording();
} }

Loading…
Cancel
Save