From bafc47fe100002e37c7abcada3dc44f3bfb66f62 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Thu, 23 Sep 2021 11:16:53 -0400
Subject: a bunch of fixes to audio timelines to support undoing clips,
 simplifying audioWaveform and having it recompute when a clip is made.

---
 .../views/collections/CollectionStackedTimeline.tsx      | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

(limited to 'src/client/views/collections/CollectionStackedTimeline.tsx')

diff --git a/src/client/views/collections/CollectionStackedTimeline.tsx b/src/client/views/collections/CollectionStackedTimeline.tsx
index 970947b12..0985e5b2e 100644
--- a/src/client/views/collections/CollectionStackedTimeline.tsx
+++ b/src/client/views/collections/CollectionStackedTimeline.tsx
@@ -61,9 +61,10 @@ export type CollectionStackedTimelineProps = {
     endTag: string;
     mediaPath: string;
     dictationKey: string;
+    rawDuration: number;
     trimming: boolean;
-    trimStart: number;
-    trimEnd: number;
+    trimStart: () => number;
+    trimEnd: () => number;
     trimDuration: number;
     setStartTrim: (newStart: number) => void;
     setEndTrim: (newEnd: number) => void;
@@ -94,11 +95,11 @@ export class CollectionStackedTimeline extends CollectionSubView<
     }
 
     get trimStart() {
-        return this.props.trimStart;
+        return this.props.trimStart();
     }
 
     get trimEnd() {
-        return this.props.trimEnd;
+        return this.props.trimEnd();
     }
 
     get duration() {
@@ -540,6 +541,7 @@ export class CollectionStackedTimeline extends CollectionSubView<
         return !this.props.mediaPath ? null : (
             <div className="collectionStackedTimeline-waveform">
                 <AudioWaveform
+                    rawDuration={this.props.rawDuration}
                     duration={this.duration}
                     mediaPath={this.props.mediaPath}
                     layoutDoc={this.layoutDoc}
@@ -584,11 +586,7 @@ export class CollectionStackedTimeline extends CollectionSubView<
                         : Math.max((start - this.trimStart) / this.props.trimDuration * timelineContentWidth, 0);
                     const top = (d.level / maxLevel) * this.timelineContentHeight() + 15;
                     const timespan = end - start;
-                    let width = (timespan / this.props.trimDuration) * timelineContentWidth;
-                    width = (!this.props.trimming && left == 0) ?
-                        width - ((this.trimStart - start) / this.props.trimDuration * timelineContentWidth) : width;
-                    width = (!this.props.trimming && this.trimEnd < end) ?
-                        width - ((end - this.trimEnd) / this.props.trimDuration * timelineContentWidth) : width;
+                    const width = (timespan / this.duration) * timelineContentWidth;
                     const height = (this.timelineContentHeight()) / maxLevel;
                     return this.props.Document.hideAnchors ? null : (
                         <div
-- 
cgit v1.2.3-70-g09d2

