fix: Fix issues with lazy loading and overridden configuration (#2012)

- Closes #2011
This commit is contained in:
Dermot Duffy
2025-04-15 17:10:18 +01:00
committed by GitHub
parent 54ee1e1cf3
commit 168b9b0c90
4 changed files with 62 additions and 48 deletions
+7 -8
View File
@@ -69,11 +69,16 @@ export class AdvancedCameraCardViewerProvider extends LitElement implements Medi
public cardWideConfig?: CardWideConfig;
protected _refProvider: Ref<MediaPlayerElement> = createRef();
protected _lazyLoadController: LazyLoadController | null = null;
protected _lazyLoadController: LazyLoadController = new LazyLoadController(this);
@state()
protected _url: string | null = null;
constructor() {
super();
this._lazyLoadController.addListener((loaded) => loaded && this._setURL());
}
public async getMediaPlayerController(): Promise<MediaPlayerController | null> {
await this.updateComplete;
return (await this._refProvider.value?.getMediaPlayerController()) ?? null;
@@ -184,13 +189,7 @@ export class AdvancedCameraCardViewerProvider extends LitElement implements Medi
changedProps.has('viewerConfig') ||
(!this._lazyLoadController && this.viewerConfig)
) {
this._lazyLoadController?.destroy();
this._lazyLoadController?.removeController();
this._lazyLoadController = new LazyLoadController(
this,
this.viewerConfig?.lazy_load,
);
this._lazyLoadController.addListener((loaded) => loaded && this._setURL());
this._lazyLoadController.setConfiguration(this.viewerConfig?.lazy_load);
}
if (