Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wake-lock #413

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ <h1>Snapdrop</h1>
</svg>
<!-- Scripts -->
<script src="scripts/network.js"></script>
<script src="scripts/nosleep.min.js"></script>
<script src="scripts/ui.js"></script>
<script src="scripts/theme.js" async></script>
<script src="scripts/clipboard.js" async></script>
Expand Down
2 changes: 2 additions & 0 deletions client/scripts/nosleep.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions client/scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,20 @@ class Snapdrop {
const notifications = new Notifications();
const networkStatusUI = new NetworkStatusUI();
const webShareTargetUI = new WebShareTargetUI();

this.lockScreen();
});
}

lockScreen() {
const noSleep = new NoSleep();

try {
noSleep.enable();
} catch (err) {
Events.fire('notify-user', 'Your browser doesn\'t support screen locking. Your display will dim after a short period of time.');
}
}
}

const snapdrop = new Snapdrop();
Expand Down
1 change: 1 addition & 0 deletions client/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var urlsToCache = [
'scripts/ui.js',
'scripts/clipboard.js',
'scripts/theme.js',
'script/nosleep.min.js',
'sounds/blop.mp3',
'images/favicon-96x96.png'
];
Expand Down