refactor: Cache device information centrally (#1598)

This commit is contained in:
Dermot Duffy
2024-09-29 17:17:40 -07:00
committed by GitHub
parent 02fb6e1d4c
commit 9393722fa6
14 changed files with 281 additions and 93 deletions
+11
View File
@@ -2,6 +2,10 @@ import { LovelaceCardEditor } from '@dermotduffy/custom-card-helpers';
import { ReactiveController } from 'lit';
import { CameraManager } from '../camera-manager/manager';
import { FrigateCardConfig } from '../config/types';
import {
createDeviceRegistryCache,
DeviceRegistryManager,
} from '../utils/ha/registry/device';
import {
createEntityRegistryCache,
EntityRegistryManager,
@@ -90,6 +94,9 @@ export class CardController
{
// These properties may be used in the construction of 'managers' (and should
// be created first).
protected _deviceRegistryManager = new DeviceRegistryManager(
createDeviceRegistryCache(),
);
protected _entityRegistryManager = new EntityRegistryManager(
createEntityRegistryCache(),
);
@@ -178,6 +185,10 @@ export class CardController
return this._defaultManager;
}
public getDeviceRegistryManager(): DeviceRegistryManager {
return this._deviceRegistryManager;
}
public getDownloadManager(): DownloadManager {
return this._downloadManager;
}