Skip to content

Commit

Permalink
Hide hidden updates from sidebar/settings (#21058)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Jun 10, 2024
1 parent 0d48921 commit d36bbfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/ha-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ class HaSidebar extends SubscribeMixin(LitElement) {
for (const entityId of Object.keys(this.hass.states)) {
if (
entityId.startsWith("update.") &&
!this.hass.entities[entityId]?.hidden &&
updateCanInstall(this.hass.states[entityId] as UpdateEntity)
) {
updateCount++;
Expand Down
16 changes: 12 additions & 4 deletions src/panels/config/dashboard/ha-config-dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
mdiPower,
mdiRefresh,
} from "@mdi/js";
import { HassEntities, UnsubscribeFunc } from "home-assistant-js-websocket";
import type { UnsubscribeFunc } from "home-assistant-js-websocket";
import {
CSSResultGroup,
LitElement,
Expand Down Expand Up @@ -177,7 +177,10 @@ class HaConfigDashboard extends SubscribeMixin(LitElement) {

protected render(): TemplateResult {
const { updates: canInstallUpdates, total: totalUpdates } =
this._filterUpdateEntitiesWithInstall(this.hass.states);
this._filterUpdateEntitiesWithInstall(
this.hass.states,
this.hass.entities
);

const { issues: repairsIssues, total: totalRepairIssues } =
this._repairsIssues;
Expand Down Expand Up @@ -306,8 +309,13 @@ class HaConfigDashboard extends SubscribeMixin(LitElement) {
}

private _filterUpdateEntitiesWithInstall = memoizeOne(
(entities: HassEntities): { updates: UpdateEntity[]; total: number } => {
const updates = filterUpdateEntitiesWithInstall(entities);
(
entities: HomeAssistant["states"],
entityRegistry: HomeAssistant["entities"]
): { updates: UpdateEntity[]; total: number } => {
const updates = filterUpdateEntitiesWithInstall(entities).filter(
(entity) => !entityRegistry[entity.entity_id]?.hidden
);

return {
updates: updates.slice(0, updates.length === 3 ? updates.length : 2),
Expand Down

0 comments on commit d36bbfe

Please sign in to comment.