Refactor for minor optimizations

This commit is contained in:
DigiLive
2025-05-01 20:18:46 +02:00
parent 11d41154de
commit aa73667809
4 changed files with 10 additions and 7 deletions

View File

@@ -161,7 +161,9 @@ class Registry {
}));
// Process entries of the HASS area registry.
if (!Registry.strategyOptions.areas._?.hidden) {
if (Registry.strategyOptions.areas._?.hidden) {
Registry._areas = [];
} else {
// Create and add the undisclosed area if not hidden in the strategy options.
if (!Registry.strategyOptions.areas.undisclosed?.hidden) {
Registry.areas.push(ConfigurationDefaults.areas.undisclosed);
@@ -179,8 +181,6 @@ class Registry {
// Remove hidden areas if configured as so and sort them by name.
Registry._areas = new RegistryFilter(Registry.areas).isNotHidden().orderBy(['order', 'name'], 'asc').toList();
} else {
Registry._areas = [];
}
// Sort views by order first and then by title.

View File

@@ -1,3 +1,5 @@
// noinspection JSUnusedGlobalSymbols
import { Registry } from '../Registry';
import { DeviceRegistryEntry } from '../types/homeassistant/data/device_registry';
import { EntityCategory, EntityRegistryEntry } from '../types/homeassistant/data/entity_registry';
@@ -25,7 +27,7 @@ class RegistryFilter<T extends RegistryEntry, K extends keyof T = keyof T> {
constructor(entries: T[]) {
this.entries = entries;
this.entryIdentifier = (
entries.length == 0 || 'entity_id' in entries[0] ? 'entity_id' : 'floor_id' in entries[0] ? 'floor_id' : 'id'
entries.length === 0 || 'entity_id' in entries[0] ? 'entity_id' : 'floor_id' in entries[0] ? 'floor_id' : 'id'
) as ('entity_id' | 'floor_id' | 'id') & K;
}

View File

@@ -19,6 +19,7 @@ export enum DebugLevel {
Fatal = 5,
}
// noinspection JSUnusedGlobalSymbols
/**
* Individually exported log level constants.
*

View File

@@ -249,9 +249,9 @@ class HomeView extends AbstractView {
// FIXME: The columns are too narrow when having HASS area cards.
return {
type: 'vertical-stack',
title: !(Registry.strategyOptions.home_view.hidden as HomeViewSections[]).includes('areasTitle')
? localize('generic.areas')
: undefined,
title: (Registry.strategyOptions.home_view.hidden as HomeViewSections[]).includes('areasTitle')
? undefined
: localize('generic.areas'),
cards: Registry.stackHorizontal(cardConfigurations, 2),
};
}