Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
Fix #258, keep onEnd/onError from firing after cancellation
Browse files Browse the repository at this point in the history
This was specific to the recorder page, i.e., regressed due to the recorder.
  • Loading branch information
ianb committed Sep 18, 2019
1 parent dd94112 commit 1c66c4c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions extension/popup/voiceShim.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ this.voiceShim = (function() {
exports.Recorder = class Recorder {
constructor() {
this._cachedVolumeLevel = 0;
this._cancelled = false;
if (activeRecorder) {
throw new Error("new voiceShim.Recorder() called twice");
}
Expand Down Expand Up @@ -43,6 +44,7 @@ this.voiceShim = (function() {
}

cancel() {
this._cancelled = true;
this.stop();
}

Expand Down Expand Up @@ -81,6 +83,12 @@ this.voiceShim = (function() {
return null;
}
const args = message.args || [];
if (
activeRecorder._cancelled &&
["onEnd", "onError"].includes(message.method)
) {
return null;
}
return activeRecorder[message.method](...args);
}
return null;
Expand Down

0 comments on commit 1c66c4c

Please sign in to comment.