Skip to content

Commit

Permalink
Make enable return a Promise to avoid 'Unhandled Promise Rejection'.
Browse files Browse the repository at this point in the history
Fixes #104
  • Loading branch information
richtr committed Dec 15, 2020
1 parent 7aa6c05 commit 04c415b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
5 changes: 3 additions & 2 deletions dist/NoSleep.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ var NoSleep = function () {
var _this2 = this;

if (nativeWakeLock) {
navigator.wakeLock.request("screen").then(function (wakeLock) {
return navigator.wakeLock.request("screen").then(function (wakeLock) {
_this2._wakeLock = wakeLock;
console.log("Wake Lock active.");
_this2._wakeLock.addEventListener("release", function () {
Expand All @@ -196,8 +196,9 @@ var NoSleep = function () {
window.setTimeout(window.stop, 0);
}
}, 15000);
return Promise.resolve();
} else {
this.noSleepVideo.play();
return this.noSleepVideo.play();
}
}
}, {
Expand Down
Loading

0 comments on commit 04c415b

Please sign in to comment.