Revert "chat, publish: avoid race condition in writeText"

This reverts commit 7febf927fa.
This commit is contained in:
Matilde Park 2020-03-10 19:44:23 -04:00
parent ee887caced
commit f58b3d6d0c
2 changed files with 10 additions and 20 deletions

View File

@ -85,17 +85,12 @@ export function writeText(str) {
e.preventDefault();
success = true;
}
document.addEventListener("copy", listener);
document.execCommand("copy");
document.removeEventListener("copy", listener);
let copyListener = new Promise(function() {
document.addEventListener("copy", listener);
document.execCommand("copy");
document.removeEventListener("copy", listener);
document.getSelection().removeAllRanges();
document.getSelection().removeAllRanges();
})
copyListener.then(() => {
return success ? resolve() : reject();
})
success ? resolve() : reject();
});
};

View File

@ -60,17 +60,12 @@ export function writeText(str) {
e.preventDefault();
success = true;
}
document.addEventListener("copy", listener);
document.execCommand("copy");
document.removeEventListener("copy", listener);
let copyListener = new Promise(function () {
document.addEventListener("copy", listener);
document.execCommand("copy");
document.removeEventListener("copy", listener);
document.getSelection().removeAllRanges();
document.getSelection().removeAllRanges();
})
copyListener.then(() => {
return success ? resolve() : reject();
})
success ? resolve() : reject();
});
};