From 5246698541d2d869089cc191461caa35347c59f4 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Fri, 21 May 2021 13:28:56 -0700 Subject: [PATCH] Fix audio recordings --- js/views/recorder_view.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/js/views/recorder_view.js b/js/views/recorder_view.js index 3cb31bc80bec..7406166e7a23 100644 --- a/js/views/recorder_view.js +++ b/js/views/recorder_view.js @@ -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(); @@ -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. @@ -81,7 +80,7 @@ } this.context = null; - this.remove(); + Whisper.View.prototype.remove.call(this); this.trigger('closed'); $(window).off('blur', this.onSwitchAwayBound); @@ -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; @@ -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 @@ -135,7 +131,7 @@ return; } - this.close(); + this.remove(); if (error && error.name === 'NotAllowedError') { window.log.warn(