mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Avoid entity registry subscribe for the media browser (#16537)
This commit is contained in:
parent
e8521c59eb
commit
ed1784b70f
@ -11,7 +11,6 @@ import {
|
|||||||
mdiStop,
|
mdiStop,
|
||||||
mdiVolumeHigh,
|
mdiVolumeHigh,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
|
||||||
import {
|
import {
|
||||||
css,
|
css,
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
@ -34,7 +33,6 @@ import "../../components/ha-button-menu";
|
|||||||
import "../../components/ha-circular-progress";
|
import "../../components/ha-circular-progress";
|
||||||
import "../../components/ha-icon-button";
|
import "../../components/ha-icon-button";
|
||||||
import { UNAVAILABLE } from "../../data/entity";
|
import { UNAVAILABLE } from "../../data/entity";
|
||||||
import { subscribeEntityRegistry } from "../../data/entity_registry";
|
|
||||||
import {
|
import {
|
||||||
BROWSER_PLAYER,
|
BROWSER_PLAYER,
|
||||||
cleanupMediaTitle,
|
cleanupMediaTitle,
|
||||||
@ -84,9 +82,6 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
@state() private _browserPlayer?: BrowserMediaPlayer;
|
@state() private _browserPlayer?: BrowserMediaPlayer;
|
||||||
|
|
||||||
@state()
|
|
||||||
private _hiddenEntities = new Set<string>();
|
|
||||||
|
|
||||||
private _progressInterval?: number;
|
private _progressInterval?: number;
|
||||||
|
|
||||||
private _browserPlayerVolume = 0.8;
|
private _browserPlayerVolume = 0.8;
|
||||||
@ -469,7 +464,7 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
(entity) =>
|
(entity) =>
|
||||||
computeStateDomain(entity) === "media_player" &&
|
computeStateDomain(entity) === "media_player" &&
|
||||||
supportsFeature(entity, MediaPlayerEntityFeature.BROWSE_MEDIA) &&
|
supportsFeature(entity, MediaPlayerEntityFeature.BROWSE_MEDIA) &&
|
||||||
!this._hiddenEntities.has(entity.entity_id)
|
!this.hass.entities[entity.entity_id].hidden
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,28 +490,6 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override hassSubscribe(): (
|
|
||||||
| UnsubscribeFunc
|
|
||||||
| Promise<UnsubscribeFunc>
|
|
||||||
)[] {
|
|
||||||
return [
|
|
||||||
subscribeEntityRegistry(this.hass.connection, (entries) => {
|
|
||||||
const hiddenEntities = new Set<string>();
|
|
||||||
|
|
||||||
for (const entry of entries) {
|
|
||||||
if (
|
|
||||||
entry.hidden_by &&
|
|
||||||
computeDomain(entry.entity_id) === "media_player"
|
|
||||||
) {
|
|
||||||
hiddenEntities.add(entry.entity_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this._hiddenEntities = hiddenEntities;
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private _handleControlClick(e: MouseEvent): void {
|
private _handleControlClick(e: MouseEvent): void {
|
||||||
const action = (e.currentTarget! as HTMLElement).getAttribute("action")!;
|
const action = (e.currentTarget! as HTMLElement).getAttribute("action")!;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user