Restore correct image after browser tab becomes visible.

This commit is contained in:
Dermot Duffy
2022-07-24 20:03:43 -07:00
parent bca2602a86
commit b4825aafc2
+5 -2
View File
@@ -9,6 +9,7 @@ import {
unsafeCSS
} from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { live } from 'lit/directives/live.js';
import { createRef, ref, Ref } from 'lit/directives/ref.js';
import { CachedValueController } from '../cached-value-controller.js';
import defaultImage from '../images/frigate-bird-in-sky.jpg';
@@ -216,11 +217,13 @@ export class FrigateCardImage extends LitElement {
protected render(): TemplateResult | void {
const src = this._cachedValueController?.value;
// Note the use of live() below to ensure the update will restore the image
// src if it's been changed via _forceSafeImage().
return src
? html` <img
${ref(this._refImage)}
src=${src}
@load=${(ev) => {
src=${live(src)}
@load=${(ev: Event) => {
dispatchMediaShowEvent(this, ev);
}}
@error=${() => {