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>
This commit is contained in:
Robbie Trencheny 2020-02-13 17:47:08 -08:00 committed by GitHub
parent b7a84cdd60
commit ecc6fcf862
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 9 deletions

4
src/data/external.ts Normal file
View File

@ -0,0 +1,4 @@
export const isExternal =
window.externalApp ||
window.webkit?.messageHandlers?.getExternalAuth ||
location.search.includes("external_auth=1");

View File

@ -10,6 +10,7 @@ import {
} from "home-assistant-js-websocket";
import { loadTokens, saveTokens } from "../common/auth/token_storage";
import { isExternal } from "../data/external";
import { subscribePanels } from "../data/ws-panels";
import { subscribeThemes } from "../data/ws-themes";
import { subscribeUser } from "../data/ws-user";
@ -23,11 +24,6 @@ declare global {
}
}
const isExternal =
window.externalApp ||
window.webkit?.messageHandlers?.getExternalAuth ||
location.search.includes("external_auth=1");
const authProm = isExternal
? () =>
import(

View File

@ -31,6 +31,7 @@ import {
getOptimisticFrontendUserDataCollection,
CoreFrontendUserData,
} from "../../data/frontend";
import { isExternal } from "../../data/external";
import { haStyle } from "../../resources/styles";
import { HomeAssistant } from "../../types";
import { fireEvent } from "../../common/dom/fire_event";
@ -113,10 +114,14 @@ class HaPanelProfile extends LitElement {
></ha-set-vibrate-row>
`
: ""}
<ha-push-notifications-row
.narrow=${this.narrow}
.hass=${this.hass}
></ha-push-notifications-row>
${!isExternal
? html`
<ha-push-notifications-row
.narrow=${this.narrow}
.hass=${this.hass}
></ha-push-notifications-row>
`
: ""}
${this.hass.user!.is_admin
? html`
<ha-advanced-mode-row