Add error handling for camera manager calls.
This commit is contained in:
@@ -9,7 +9,7 @@ import thumbnailFeatureEventStyle from '../scss/thumbnail-feature-event.scss';
|
||||
import thumbnailFeatureRecordingStyle from '../scss/thumbnail-feature-recording.scss';
|
||||
import thumbnailStyle from '../scss/thumbnail.scss';
|
||||
import { stopEventFromActivatingCardWideActions } from '../utils/action.js';
|
||||
import { getDurationString, prettifyTitle } from '../utils/basic.js';
|
||||
import { errorToConsole, getDurationString, prettifyTitle } from '../utils/basic.js';
|
||||
import { getCameraTitle } from '../utils/camera.js';
|
||||
import { renderTask } from '../utils/task.js';
|
||||
import { createFetchThumbnailTask } from '../utils/thumbnail.js';
|
||||
@@ -289,20 +289,26 @@ export class FrigateCardThumbnail extends LitElement {
|
||||
.date=${this.media.getStartTime() ?? undefined}
|
||||
></frigate-card-thumbnail-feature-recording>`
|
||||
: html``}
|
||||
${this.show_favorite_control && event && this.hass && clientID
|
||||
${this.show_favorite_control && this.media && this.hass && clientID
|
||||
? html` <ha-icon
|
||||
class="${classMap(starClasses)}"
|
||||
icon=${this.media.isFavorite() ? 'mdi:star' : 'mdi:star-outline'}
|
||||
title=${localize('thumbnail.retain_indefinitely')}
|
||||
@click=${(ev: Event) => {
|
||||
@click=${async (ev: Event) => {
|
||||
stopEventFromActivatingCardWideActions(ev);
|
||||
if (this.hass && this.cameraConfig && this.media) {
|
||||
this.cameraManager?.favoriteMedia(
|
||||
this.hass,
|
||||
this.cameraConfig,
|
||||
this.media,
|
||||
!this.media?.isFavorite(),
|
||||
);
|
||||
try {
|
||||
await this.cameraManager?.favoriteMedia(
|
||||
this.hass,
|
||||
this.cameraConfig,
|
||||
this.media,
|
||||
!this.media?.isFavorite(),
|
||||
);
|
||||
} catch (e) {
|
||||
errorToConsole(e as Error);
|
||||
return;
|
||||
}
|
||||
this.requestUpdate();
|
||||
}
|
||||
}}
|
||||
/></ha-icon>`
|
||||
|
||||
@@ -471,6 +471,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
['background', 'group-label'].includes(properties.what)
|
||||
) {
|
||||
view = await createViewForRecordings(
|
||||
this,
|
||||
this.hass,
|
||||
this.cameraManager,
|
||||
this.cameras,
|
||||
@@ -487,6 +488,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
);
|
||||
} else if (this.timelineConfig?.show_recordings && properties.what === 'axis') {
|
||||
view = await createViewForRecordings(
|
||||
this,
|
||||
this.hass,
|
||||
this.cameraManager,
|
||||
this.cameras,
|
||||
@@ -641,6 +643,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
return null;
|
||||
}
|
||||
const view = await createViewForEvents(
|
||||
this,
|
||||
this.hass,
|
||||
this.cameraManager,
|
||||
this.cameras,
|
||||
@@ -651,6 +654,9 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
mediaType: this.timelineConfig?.media,
|
||||
},
|
||||
);
|
||||
if (!view) {
|
||||
return null;
|
||||
}
|
||||
view.mergeInContext(
|
||||
this._generateTimelineContext({ noSetWindow: options?.noSetWindow }),
|
||||
);
|
||||
@@ -813,7 +819,8 @@ export class FrigateCardTimelineCore extends LitElement {
|
||||
);
|
||||
},
|
||||
}
|
||||
: (false as TimelineOptionsCluster),
|
||||
: // Timeline type information is incorrect requiring this 'as'.
|
||||
(false as unknown as TimelineOptionsCluster),
|
||||
minHeight: '100%',
|
||||
maxHeight: '100%',
|
||||
zoomMax: 1 * 24 * 60 * 60 * 1000,
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
ViewerConfig,
|
||||
} from '../types.js';
|
||||
import { stopEventFromActivatingCardWideActions } from '../utils/action.js';
|
||||
import { contentsChanged } from '../utils/basic.js';
|
||||
import { contentsChanged, errorToConsole } from '../utils/basic.js';
|
||||
import { getFullDependentBrowseMediaQueryParametersOrDispatchError } from '../utils/ha/browse-media.js';
|
||||
import { ResolvedMediaCache, resolveMedia } from '../utils/ha/resolved-media.js';
|
||||
import { View } from '../view/view.js';
|
||||
@@ -56,6 +56,7 @@ import { ViewMedia } from '../view/media.js';
|
||||
import { ViewMediaClassifier } from '../view/media-classifier';
|
||||
import { guard } from 'lit/directives/guard.js';
|
||||
import { localize } from '../localize/localize.js';
|
||||
import { MediaQueriesResults } from '../view/media-queries-results.js';
|
||||
|
||||
export interface MediaSeek {
|
||||
// Specifies the point at which this recording should be played, the
|
||||
@@ -384,7 +385,14 @@ export class FrigateCardViewerCarousel extends LitElement {
|
||||
const clipQuery = this.view.query.clone();
|
||||
clipQuery.convertToClipsQueries();
|
||||
|
||||
const results = await this.cameraManager.executeMediaQuery(this.hass, clipQuery);
|
||||
let results: MediaQueriesResults | null;
|
||||
try {
|
||||
results = await this.cameraManager.executeMediaQuery(this.hass, clipQuery);
|
||||
} catch (e) {
|
||||
errorToConsole(e as Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!results) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user