Skip to content

Commit

Permalink
Fix audio recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny-signal committed May 21, 2021
1 parent ffd4378 commit 5fea16f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions js/views/recorder_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@
this.start();
},
events: {
'click .close': 'close',
'click .close': 'remove',
'click .finish': 'finish',
close: 'close',
close: 'remove',
},
onSwitchAway() {
this.lostFocus = true;
this.recorder.finishRecording();
this.close();
},
handleKeyDown(event) {
if (event.key === 'Escape') {
this.close();
this.remove();

event.preventDefault();
event.stopPropagation();
Expand All @@ -51,7 +50,7 @@
}
this.$('.time').text(`${minutes}:${seconds}`);
},
close() {
remove() {
// Note: the 'close' event can be triggered by InboxView, when the user clicks
// anywhere outside the recording pane.

Expand Down Expand Up @@ -81,7 +80,7 @@
}
this.context = null;

this.remove();
Whisper.View.prototype.remove.call(this);
this.trigger('closed');

$(window).off('blur', this.onSwitchAwayBound);
Expand All @@ -91,16 +90,14 @@
finish() {
this.clickedFinish = true;
this.recorder.finishRecording();
this.close();
},
handleBlob(recorder, blob) {
if (blob && this.clickedFinish) {
this.trigger('send', blob);
} else if (blob) {
this.trigger('confirm', blob, this.lostFocus);
} else {
this.close();
}
this.remove();
},
start() {
this.lostFocus = false;
Expand All @@ -126,7 +123,6 @@
},
onTimeout() {
this.recorder.finishRecording();
this.close();
},
onError(error) {
// Protect against out-of-band errors, which can happen if the user revokes media
Expand All @@ -135,7 +131,7 @@
return;
}

this.close();
this.remove();

if (error && error.name === 'NotAllowedError') {
window.log.warn(
Expand Down

0 comments on commit 5fea16f

Please sign in to comment.