implemented NoSleep.js as suggested in this issue: https://github.com/RobinLinus/snapdrop/issues/412
This commit is contained in:
parent
474eb9290f
commit
168d10a898
4 changed files with 31 additions and 2 deletions
|
@ -288,12 +288,13 @@
|
||||||
</symbol>
|
</symbol>
|
||||||
</svg>
|
</svg>
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script src="scripts/zip.min.js" async></script>
|
|
||||||
<script src="scripts/util.js"></script>
|
<script src="scripts/util.js"></script>
|
||||||
<script src="scripts/network.js"></script>
|
<script src="scripts/network.js"></script>
|
||||||
<script src="scripts/qrcode.js" async></script>
|
|
||||||
<script src="scripts/ui.js"></script>
|
<script src="scripts/ui.js"></script>
|
||||||
<script src="scripts/theme.js" async></script>
|
<script src="scripts/theme.js" async></script>
|
||||||
|
<script src="scripts/qrcode.js" async></script>
|
||||||
|
<script src="scripts/zip.min.js" async></script>
|
||||||
|
<script src="scripts/NoSleep.min.js" async></script>
|
||||||
<!-- Sounds -->
|
<!-- Sounds -->
|
||||||
<audio id="blop" autobuffer="true">
|
<audio id="blop" autobuffer="true">
|
||||||
<source src="/sounds/blop.mp3" type="audio/mpeg">
|
<source src="/sounds/blop.mp3" type="audio/mpeg">
|
||||||
|
|
2
public/scripts/NoSleep.min.js
vendored
Normal file
2
public/scripts/NoSleep.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -284,6 +284,8 @@ class PeerUI {
|
||||||
_bindListeners(el) {
|
_bindListeners(el) {
|
||||||
if(!window.pasteMode.activated) {
|
if(!window.pasteMode.activated) {
|
||||||
el.querySelector('input').addEventListener('change', e => this._onFilesSelected(e));
|
el.querySelector('input').addEventListener('change', e => this._onFilesSelected(e));
|
||||||
|
el.addEventListener('click', _ => NoSleepUI.enable());
|
||||||
|
el.addEventListener('touchstart', _ => NoSleepUI.enable());
|
||||||
el.addEventListener('drop', e => this._onDrop(e));
|
el.addEventListener('drop', e => this._onDrop(e));
|
||||||
el.addEventListener('dragend', e => this._onDragEnd(e));
|
el.addEventListener('dragend', e => this._onDragEnd(e));
|
||||||
el.addEventListener('dragleave', e => this._onDragEnd(e));
|
el.addEventListener('dragleave', e => this._onDragEnd(e));
|
||||||
|
@ -435,6 +437,7 @@ class ReceiveDialog extends Dialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReceiveFileDialog extends ReceiveDialog {
|
class ReceiveFileDialog extends ReceiveDialog {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -642,6 +645,7 @@ class ReceiveRequestDialog extends ReceiveDialog {
|
||||||
this.requestingPeerId = null;
|
this.requestingPeerId = null;
|
||||||
if (accepted) {
|
if (accepted) {
|
||||||
Events.fire('set-progress', {peerId: this._peerId, progress: 0, status: 'wait'});
|
Events.fire('set-progress', {peerId: this._peerId, progress: 0, status: 'wait'});
|
||||||
|
NoSleepUI.enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,6 +1149,26 @@ class WebShareTargetUI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NoSleepUI {
|
||||||
|
constructor() {
|
||||||
|
NoSleepUI._nosleep = new NoSleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
static enable() {
|
||||||
|
if (!this._interval) {
|
||||||
|
NoSleepUI._nosleep.enable();
|
||||||
|
NoSleepUI._interval = setInterval(_ => NoSleepUI.disable(), 10000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static disable() {
|
||||||
|
if ($$('x-peer[status]') === null) {
|
||||||
|
clearInterval(NoSleepUI._interval);
|
||||||
|
NoSleepUI._nosleep.disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PersistentStorage {
|
class PersistentStorage {
|
||||||
constructor() {
|
constructor() {
|
||||||
if (!('indexedDB' in window)) {
|
if (!('indexedDB' in window)) {
|
||||||
|
@ -1337,6 +1361,7 @@ class PairDrop {
|
||||||
const notifications = new Notifications();
|
const notifications = new Notifications();
|
||||||
const networkStatusUI = new NetworkStatusUI();
|
const networkStatusUI = new NetworkStatusUI();
|
||||||
const webShareTargetUI = new WebShareTargetUI();
|
const webShareTargetUI = new WebShareTargetUI();
|
||||||
|
const noSleepUI = new NoSleepUI();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ var urlsToCache = [
|
||||||
'scripts/util.js',
|
'scripts/util.js',
|
||||||
'scripts/qrcode.js',
|
'scripts/qrcode.js',
|
||||||
'scripts/zip.min.js',
|
'scripts/zip.min.js',
|
||||||
|
'scripts/NoSleep.min.js',
|
||||||
'scripts/theme.js',
|
'scripts/theme.js',
|
||||||
'sounds/blop.mp3',
|
'sounds/blop.mp3',
|
||||||
'images/favicon-96x96.png'
|
'images/favicon-96x96.png'
|
||||||
|
|
Loading…
Reference in a new issue