Skip to content

Commit eb58bc8

Browse files
committed
Add screen wakelock
1 parent 447096b commit eb58bc8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

public/challenge-counter.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,22 @@ class ChallengeCounter extends LitElement {
3636

3737
async connectedCallback() {
3838
super.connectedCallback();
39+
this.requestWakeLock();
3940
this.checkUser();
4041
supabase.auth.onAuthStateChange(async () => {
4142
this.checkUser();
4243
});
4344
}
4445

46+
async requestWakeLock() {
47+
// see https://whatpwacando.today/wake-lock
48+
try {
49+
await navigator.wakeLock.request('screen');
50+
} catch (error) {
51+
console.error(`${error.name}, ${error.message}`);
52+
}
53+
}
54+
4555
async checkUser() {
4656
const {
4757
data: { session },

0 commit comments

Comments
 (0)