Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Do not copy while copying. (#3878)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenba committed Dec 7, 2017
1 parent 05b44b4 commit b64c417
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion addon/webextension/selector/shooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,30 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
}));
};

let copyInProgress = null;
exports.copyShot = function(selectedPos) {
// This is pretty slow. We'll ignore additional user triggered copy events
// while it is in progress.
if (copyInProgress) {
return;
}
// A max of five seconds in case some error occurs.
copyInProgress = setTimeout(() => {
copyInProgress = null;
}, 5000);

let unsetCopyInProgress = () => {
if (copyInProgress) {
clearTimeout(copyInProgress);
copyInProgress = null;
}
}
let dataUrl = screenshotPage(selectedPos);
let blob = blobConverters.dataUrlToBlob(dataUrl);
catcher.watchPromise(callBackground("copyShotToClipboard", blob).then(() => {
uicontrol.deactivate();
}));
unsetCopyInProgress();
}, unsetCopyInProgress));
};

exports.sendEvent = function(...args) {
Expand Down

0 comments on commit b64c417

Please sign in to comment.