Skip to content

Commit 1371697

Browse files
committed
Respect wake lock setting
1 parent 9d15c76 commit 1371697

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/components/modals/SettingsModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<hr>
2323
<template v-if="$browser.supportsWakeLocking">
2424
<CoreToggle
25-
v-model="$kitchen.wakeLock"
25+
v-model="$kitchen.useWakeLock"
2626
class="p-4"
2727
:label="$t('settings.wakeLock')"
2828
:description="$t('settings.wakeLock_description')"

src/services/KitchenService.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface State {
2525
dishes: Dish[];
2626
timers: Timer[];
2727
dismissedAt: Date | null;
28-
wakeLock: boolean;
28+
useWakeLock: boolean;
2929
lastPage: {
3030
route: RouteLocationRaw;
3131
showLogo: boolean;
@@ -40,7 +40,7 @@ interface ComputedState {
4040
interface PersistedState {
4141
dishes: DishJson[];
4242
timers: TimerJson[];
43-
wakeLock: boolean;
43+
useWakeLock: boolean;
4444
dismissedAt: number | null;
4545
lastPage: {
4646
route: RouteLocationRaw;
@@ -53,7 +53,13 @@ const DAY_MILLISECONDS = 24 * 60 * 60 * 1000;
5353

5454
export default class CookbookService extends Service<State, ComputedState, PersistedState> {
5555

56-
public static persist: Array<keyof PersistedState> = ['dishes', 'timers', 'wakeLock', 'dismissedAt', 'lastPage'];
56+
public static persist: Array<keyof PersistedState> = [
57+
'dishes',
58+
'timers',
59+
'useWakeLock',
60+
'dismissedAt',
61+
'lastPage',
62+
];
5763

5864
private screenLock: Promise<void | { release(): Promise<void> }> | null = null;
5965
private timeouts: WeakMap<Timer, ReturnType<typeof setTimeout>> = new WeakMap();
@@ -197,7 +203,7 @@ export default class CookbookService extends Service<State, ComputedState, Persi
197203
dishes: [],
198204
timers: [],
199205
dismissedAt: null,
200-
wakeLock: true,
206+
useWakeLock: true,
201207
lastPage: null,
202208
};
203209
}
@@ -288,7 +294,7 @@ export default class CookbookService extends Service<State, ComputedState, Persi
288294
wakeLock?: { request(type?: 'screen'): Promise<{ release(): Promise<void> }> };
289295
};
290296

291-
if (!Browser.supportsWakeLocking || !typedNavigator.wakeLock) {
297+
if (!this.useWakeLock || !Browser.supportsWakeLocking || !typedNavigator.wakeLock) {
292298
return;
293299
}
294300

0 commit comments

Comments
 (0)