mirror of
https://github.com/DigiLive/mushroom-strategy.git
synced 2025-08-02 19:14:27 +02:00
Refactor for minor optimizations
This commit is contained in:
@@ -161,7 +161,9 @@ class Registry {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Process entries of the HASS area 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.
|
// Create and add the undisclosed area if not hidden in the strategy options.
|
||||||
if (!Registry.strategyOptions.areas.undisclosed?.hidden) {
|
if (!Registry.strategyOptions.areas.undisclosed?.hidden) {
|
||||||
Registry.areas.push(ConfigurationDefaults.areas.undisclosed);
|
Registry.areas.push(ConfigurationDefaults.areas.undisclosed);
|
||||||
@@ -179,8 +181,6 @@ class Registry {
|
|||||||
// Remove hidden areas if configured as so and sort them by name.
|
// Remove hidden areas if configured as so and sort them by name.
|
||||||
|
|
||||||
Registry._areas = new RegistryFilter(Registry.areas).isNotHidden().orderBy(['order', 'name'], 'asc').toList();
|
Registry._areas = new RegistryFilter(Registry.areas).isNotHidden().orderBy(['order', 'name'], 'asc').toList();
|
||||||
} else {
|
|
||||||
Registry._areas = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort views by order first and then by title.
|
// Sort views by order first and then by title.
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
// noinspection JSUnusedGlobalSymbols
|
||||||
|
|
||||||
import { Registry } from '../Registry';
|
import { Registry } from '../Registry';
|
||||||
import { DeviceRegistryEntry } from '../types/homeassistant/data/device_registry';
|
import { DeviceRegistryEntry } from '../types/homeassistant/data/device_registry';
|
||||||
import { EntityCategory, EntityRegistryEntry } from '../types/homeassistant/data/entity_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[]) {
|
constructor(entries: T[]) {
|
||||||
this.entries = entries;
|
this.entries = entries;
|
||||||
this.entryIdentifier = (
|
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;
|
) as ('entity_id' | 'floor_id' | 'id') & K;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ export enum DebugLevel {
|
|||||||
Fatal = 5,
|
Fatal = 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// noinspection JSUnusedGlobalSymbols
|
||||||
/**
|
/**
|
||||||
* Individually exported log level constants.
|
* Individually exported log level constants.
|
||||||
*
|
*
|
||||||
|
@@ -249,9 +249,9 @@ class HomeView extends AbstractView {
|
|||||||
// FIXME: The columns are too narrow when having HASS area cards.
|
// FIXME: The columns are too narrow when having HASS area cards.
|
||||||
return {
|
return {
|
||||||
type: 'vertical-stack',
|
type: 'vertical-stack',
|
||||||
title: !(Registry.strategyOptions.home_view.hidden as HomeViewSections[]).includes('areasTitle')
|
title: (Registry.strategyOptions.home_view.hidden as HomeViewSections[]).includes('areasTitle')
|
||||||
? localize('generic.areas')
|
? undefined
|
||||||
: undefined,
|
: localize('generic.areas'),
|
||||||
cards: Registry.stackHorizontal(cardConfigurations, 2),
|
cards: Registry.stackHorizontal(cardConfigurations, 2),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user