mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Keep screen on while adding new ZwaveJS device (#25375)
* Keep screen on while adding new ZwaveJS device * Add compatibility check * Update src/mixins/wakelock-mixin.ts Co-authored-by: Bram Kragten <mail@bramkragten.nl> * format --------- Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
4b270eb444
commit
55cf7e635d
21
src/mixins/wakelock-mixin.ts
Normal file
21
src/mixins/wakelock-mixin.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import type { ReactiveElement } from "lit";
|
||||||
|
import type { Constructor } from "../types";
|
||||||
|
|
||||||
|
export const WakeLockMixin = <T extends Constructor<ReactiveElement>>(
|
||||||
|
superClass: T
|
||||||
|
) =>
|
||||||
|
class WakeLockClass extends superClass {
|
||||||
|
private _wakeLock?: Promise<WakeLockSentinel>;
|
||||||
|
|
||||||
|
public connectedCallback() {
|
||||||
|
super.connectedCallback();
|
||||||
|
if ("wakeLock" in navigator) {
|
||||||
|
this._wakeLock = navigator.wakeLock.request();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this._wakeLock?.then((wakeLock) => wakeLock.release());
|
||||||
|
}
|
||||||
|
};
|
@ -48,7 +48,6 @@ import "../../../../../../components/ha-dialog-header";
|
|||||||
import "../../../../../../components/ha-fade-in";
|
import "../../../../../../components/ha-fade-in";
|
||||||
import "../../../../../../components/ha-icon-button";
|
import "../../../../../../components/ha-icon-button";
|
||||||
import "../../../../../../components/ha-qr-scanner";
|
import "../../../../../../components/ha-qr-scanner";
|
||||||
import "../../../../../../components/ha-spinner";
|
|
||||||
|
|
||||||
import { computeStateName } from "../../../../../../common/entity/compute_state_name";
|
import { computeStateName } from "../../../../../../common/entity/compute_state_name";
|
||||||
import { navigate } from "../../../../../../common/navigate";
|
import { navigate } from "../../../../../../common/navigate";
|
||||||
|
@ -3,9 +3,10 @@ import { css, html, LitElement, nothing } from "lit";
|
|||||||
|
|
||||||
import "../../../../../../components/ha-fade-in";
|
import "../../../../../../components/ha-fade-in";
|
||||||
import "../../../../../../components/ha-spinner";
|
import "../../../../../../components/ha-spinner";
|
||||||
|
import { WakeLockMixin } from "../../../../../../mixins/wakelock-mixin";
|
||||||
|
|
||||||
@customElement("zwave-js-add-node-loading")
|
@customElement("zwave-js-add-node-loading")
|
||||||
export class ZWaveJsAddNodeLoading extends LitElement {
|
export class ZWaveJsAddNodeLoading extends WakeLockMixin(LitElement) {
|
||||||
@property() public description?: string;
|
@property() public description?: string;
|
||||||
|
|
||||||
@property({ type: Number }) public delay = 0;
|
@property({ type: Number }) public delay = 0;
|
||||||
|
@ -10,9 +10,10 @@ import { InclusionStrategy } from "../../../../../../data/zwave_js";
|
|||||||
import "../../../../../../components/ha-spinner";
|
import "../../../../../../components/ha-spinner";
|
||||||
import "../../../../../../components/ha-button";
|
import "../../../../../../components/ha-button";
|
||||||
import "../../../../../../components/ha-alert";
|
import "../../../../../../components/ha-alert";
|
||||||
|
import { WakeLockMixin } from "../../../../../../mixins/wakelock-mixin";
|
||||||
|
|
||||||
@customElement("zwave-js-add-node-searching-devices")
|
@customElement("zwave-js-add-node-searching-devices")
|
||||||
export class ZWaveJsAddNodeSearchingDevices extends LitElement {
|
export class ZWaveJsAddNodeSearchingDevices extends WakeLockMixin(LitElement) {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property({ type: Boolean, attribute: "smart-start" })
|
@property({ type: Boolean, attribute: "smart-start" })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user