From 878842ab6d69d089cc483c8b160440be4af50106 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Thu, 9 Feb 2023 19:57:55 -0800 Subject: [PATCH] Fix timeline button for recordings. --- src/components/thumbnail.ts | 122 +++++++++++++++--------------------- 1 file changed, 49 insertions(+), 73 deletions(-) diff --git a/src/components/thumbnail.ts b/src/components/thumbnail.ts index 84e95fc2..65170344 100644 --- a/src/components/thumbnail.ts +++ b/src/components/thumbnail.ts @@ -104,12 +104,12 @@ export class FrigateCardThumbnailFeatureEvent extends LitElement { return html`${this.thumbnail ? renderTask( - this, - this._embedThumbnailTask, - (embeddedThumbnail: string | null) => - embeddedThumbnail ? html`` : html``, - { inProgressFunc: () => imageOff }, - ) + this, + this._embedThumbnailTask, + (embeddedThumbnail: string | null) => + embeddedThumbnail ? html`` : html``, + { inProgressFunc: () => imageOff }, + ) : imageOff} `; } @@ -162,7 +162,7 @@ export class FrigateCardThumbnailDetailsEvent extends LitElement { return html`
${what ? html`
${prettifyTitle(what.join(', '))}
` : ``} ${startTime - ? html`
+ ? html`
${localize('event.start')}: ${format(startTime, 'HH:mm:ss')}
@@ -170,17 +170,17 @@ export class FrigateCardThumbnailDetailsEvent extends LitElement { ${localize('event.duration')}: ${endTime - ? getDurationString(startTime, endTime) - : localize('event.in_progress')}
` - : ``} + : ``} ${this.seek - ? html`
+ ? html`
${localize('event.seek')} ${format(this.seek, 'HH:mm:ss')}
` - : html``} + : html``}
${score ? html`
@@ -213,11 +213,11 @@ export class FrigateCardThumbnailDetailsRecording extends LitElement { return html`
${this.cameraTitle ?? ''}
${this.seek - ? html`
+ ? html`
${localize('recording.seek')} ${format(this.seek, 'HH:mm:ss')}
` - : html``} + : html``}
${eventCount !== null ? html`
@@ -303,50 +303,50 @@ export class FrigateCardThumbnail extends LitElement { .thumbnail=${thumbnail ?? undefined} >` : ViewMediaClassifier.isRecording(this.media) - ? html`` - : html``} + : html``} ${shouldShowFavoriteControl - ? html` { - stopEventFromActivatingCardWideActions(ev); - if (this.hass && this.media) { - try { - await this.cameraManager?.favoriteMedia( - this.hass, - this.media, - !this.media?.isFavorite(), - ); - } catch (e) { - errorToConsole(e as Error); - return; - } - this.requestUpdate(); + stopEventFromActivatingCardWideActions(ev); + if (this.hass && this.media) { + try { + await this.cameraManager?.favoriteMedia( + this.hass, + this.media, + !this.media?.isFavorite(), + ); + } catch (e) { + errorToConsole(e as Error); + return; } - }} + this.requestUpdate(); + } + }} />` - : ``} + : ``} ${this.details && ViewMediaClassifier.isEvent(this.media) - ? html`` - : this.details && ViewMediaClassifier.isRecording(this.media) - ? html`` - : html``} + : html``} ${shouldShowTimelineControl - ? html` media === this.media), - }) - .removeContext('timeline') - .dispatchChangeEvent(this); - } else if (ViewMediaClassifier.isRecording(this.media)) { - const startTime = this.media.getStartTime(); - const endTime = this.media.getStartTime(); - if (!startTime || !endTime) { - return; - } - // Specifically reset the media target/childIndex, as we cannot - // 'select' an hour in the timeline rather we set the window to - // matching values. - this.view - ?.evolve({ - view: 'timeline', - query: null, - }) - .mergeInContext({ - timeline: { - window: { - start: startTime, - end: endTime, - }, - }, - }) - .dispatchChangeEvent(this); - } - }} + this.view + .evolve({ + view: 'timeline', + queryResults: this.view.queryResults + ?.clone() + .selectResultIfFound((media) => media === this.media), + }) + .removeContext('timeline') + .dispatchChangeEvent(this); + } + } >` - : ''}`; + : ''}`; } /**