Skip to content

Commit ecc6fcf

Browse files
robbiet480balloob
andauthored
Hide HTML5 push notification toggle if inside external app (#4860)
* Hide HTML5 push notification toggle if external bus is engaged * Use isExternal instead * Hide the whole row * Black * Fix import Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
1 parent b7a84cd commit ecc6fcf

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/data/external.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const isExternal =
2+
window.externalApp ||
3+
window.webkit?.messageHandlers?.getExternalAuth ||
4+
location.search.includes("external_auth=1");

src/entrypoints/core.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from "home-assistant-js-websocket";
1111

1212
import { loadTokens, saveTokens } from "../common/auth/token_storage";
13+
import { isExternal } from "../data/external";
1314
import { subscribePanels } from "../data/ws-panels";
1415
import { subscribeThemes } from "../data/ws-themes";
1516
import { subscribeUser } from "../data/ws-user";
@@ -23,11 +24,6 @@ declare global {
2324
}
2425
}
2526

26-
const isExternal =
27-
window.externalApp ||
28-
window.webkit?.messageHandlers?.getExternalAuth ||
29-
location.search.includes("external_auth=1");
30-
3127
const authProm = isExternal
3228
? () =>
3329
import(

src/panels/profile/ha-panel-profile.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
getOptimisticFrontendUserDataCollection,
3232
CoreFrontendUserData,
3333
} from "../../data/frontend";
34+
import { isExternal } from "../../data/external";
3435
import { haStyle } from "../../resources/styles";
3536
import { HomeAssistant } from "../../types";
3637
import { fireEvent } from "../../common/dom/fire_event";
@@ -113,10 +114,14 @@ class HaPanelProfile extends LitElement {
113114
></ha-set-vibrate-row>
114115
`
115116
: ""}
116-
<ha-push-notifications-row
117-
.narrow=${this.narrow}
118-
.hass=${this.hass}
119-
></ha-push-notifications-row>
117+
${!isExternal
118+
? html`
119+
<ha-push-notifications-row
120+
.narrow=${this.narrow}
121+
.hass=${this.hass}
122+
></ha-push-notifications-row>
123+
`
124+
: ""}
120125
${this.hass.user!.is_admin
121126
? html`
122127
<ha-advanced-mode-row

0 commit comments

Comments
 (0)