Merge pull request #559 from dermotduffy/live-thumbnail-fetch-preload

Don't fetch thumbnails on preloaded camera in the background
This commit is contained in:
Dermot Duffy
2022-05-09 09:46:44 -07:00
committed by GitHub
3 changed files with 17 additions and 11 deletions
+7 -3
View File
@@ -139,14 +139,18 @@ export class FrigateCardLive extends LitElement {
return;
}
// Note use of liveConfig and not config below -- the carousel will
// independently override the liveconfig to reflect the camera in the
// carousel (not necessarily the selected camera).
// Notes:
// - See use of liveConfig and not config below -- the carousel will
// independently override the liveConfig to reflect the camera in the
// carousel (not necessarily the selected camera).
// - Fetching of thumbnails is disabled as long as live view is the
// background (preloaded) rather than foreground (not preloaded).
return html` <frigate-card-surround-thumbnails
.hass=${this.hass}
.view=${this.view}
.config=${config.controls.thumbnails}
.browseMediaParams=${browseMediaParams}
?fetch=${!this._preloaded}
>
<frigate-card-live-carousel
.hass=${this.hass}
+9 -7
View File
@@ -33,16 +33,18 @@ export class FrigateCardSurround extends LitElement {
@property({ attribute: false })
protected targetView?: FrigateCardView;
@property({ attribute: true, type: Boolean })
protected fetch?: boolean;
@property({ attribute: false })
protected browseMediaParams?:
| BrowseMediaQueryParameters
| BrowseMediaQueryParameters[];
// A task to await the load of the WebRTC component.
protected _browseTask = new Task(this, this._fetchMedia.bind(this), () => [
this.hass,
this.view,
this.browseMediaParams,
this.fetch,
]);
/**
@@ -51,25 +53,25 @@ export class FrigateCardSurround extends LitElement {
* @param param Task parameters.
* @returns
*/
protected async _fetchMedia([hass, view, browseMediaParams]: (
| HomeAssistant
protected async _fetchMedia([view, browseMediaParams, fetch]: (
| Readonly<View>
| BrowseMediaQueryParameters
| BrowseMediaQueryParameters[]
| boolean
| undefined
)[]): Promise<void> {
hass = hass as HomeAssistant;
view = view as Readonly<View>;
browseMediaParams = browseMediaParams as
| BrowseMediaQueryParameters
| BrowseMediaQueryParameters[];
fetch = fetch as boolean;
if (!hass || !view || view.target || !browseMediaParams) {
if (!fetch || !this.hass || !view || view.target || !browseMediaParams) {
return;
}
let parent: FrigateBrowseMediaSource | null;
try {
parent = await BrowseMediaUtil.multipleBrowseMediaQueryMerged(hass, browseMediaParams);
parent = await BrowseMediaUtil.multipleBrowseMediaQueryMerged(this.hass, browseMediaParams);
} catch (e) {
return dispatchErrorMessageEvent(this, (e as Error).message);
}
+1 -1
View File
@@ -177,9 +177,9 @@ const noActionSchema = schemaForType<
);
const frigateCardCustomactionsBaseSchema = customActionSchema.extend({
// Syntactic sugar to avoid 'fire-dom-event' as part of an external API.
action: z
.literal('custom:frigate-card-action')
// Syntactic sugar to avoid 'fire-dom-event' as part of an external API.
.transform((): 'fire-dom-event' => 'fire-dom-event')
.or(z.literal('fire-dom-event')),
});