changeset 376:35234006c3c3

Use module scoped id generator instead of passing in an id to components.
author Lucas Thompson <dev@lucas.im>
date Wed, 31 May 2017 12:55:03 +0100
parents 9f9d5731a941
children 05a817d8ba71
files src/app/analysis-item/analysis-item.component.html src/app/visualisations/curve/curve.component.ts src/app/visualisations/waves-base.component.ts
diffstat 3 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/analysis-item/analysis-item.component.html	Wed May 31 12:38:18 2017 +0100
+++ b/src/app/analysis-item/analysis-item.component.html	Wed May 31 12:55:03 2017 +0100
@@ -21,7 +21,6 @@
         </ng-template>
         <ugly-waveform *ngIf="isAudioItem(); else notAudio"
           [timeline]="timeline"
-          [trackIdPrefix]=" item.id"
           [width]="contentWidth"
           [audioBuffer]="item.audioData"
           [onSeek]="onSeek"
@@ -42,7 +41,6 @@
               <ugly-tracks
                 *ngSwitchCase="'tracks'"
                 [timeline]="timeline"
-                [trackIdPrefix]="item.id"
                 [width]="contentWidth"
                 [onSeek]="onSeek"
                 [tracks]="item.collected"
--- a/src/app/visualisations/curve/curve.component.ts	Wed May 31 12:38:18 2017 +0100
+++ b/src/app/visualisations/curve/curve.component.ts	Wed May 31 12:55:03 2017 +0100
@@ -13,7 +13,6 @@
   selector: 'ugly-curve',
   template: `<ugly-tracks
     [timeline]="timeline"
-    [trackIdPrefix]="id"
     [width]="width"
     [onSeek]="onSeek"
     [colour]="colour"
@@ -22,8 +21,7 @@
   changeDetection: ChangeDetectionStrategy.OnPush
 })
 export class CurveComponent {
-  @Input() id: string; // TODO refactor WaveComponents to have own Timeline, sharing a TimeContext
-  @Input() timeline: Timeline; // TODO as above
+  @Input() timeline: Timeline; // TODO refactor WaveComponents to have own Timeline, sharing a TimeContext
   @Input() onSeek: OnSeekHandler;
   @Input() width: number;
   @Input() curve: VectorFeature;
--- a/src/app/visualisations/waves-base.component.ts	Wed May 31 12:38:18 2017 +0100
+++ b/src/app/visualisations/waves-base.component.ts	Wed May 31 12:55:03 2017 +0100
@@ -5,6 +5,9 @@
 import {OnSeekHandler} from '../playhead/PlayHeadHelpers';
 import {attachTouchHandlerBodges} from './WavesJunk';
 import Waves from 'waves-ui-piper';
+import {countingIdProvider} from 'piper/client-stubs/WebWorkerStreamingClient';
+
+const trackIdGenerator = countingIdProvider(0);
 
 export abstract class WavesComponent {
   @Input() set width(width: number) {
@@ -16,16 +19,17 @@
     }
   }
   @Input() timeline: Timeline;
-  @Input() trackIdPrefix: string;
   @Input() onSeek: OnSeekHandler;
 
   protected layers: Layer[];
   protected zoomOnMouseDown: number;
   protected offsetOnMouseDown: number;
   protected waveTrack: Track;
+  private id: string;
 
   constructor() {
     this.layers = [];
+    this.id = trackIdGenerator.next().value;
   }
 
   protected renderTimeline($el: ElementRef, duration?: number): Timeline {
@@ -40,7 +44,7 @@
     this.waveTrack = this.timeline.createTrack(
       track,
       height,
-      `wave-${this.trackIdPrefix || 'default'}`
+      this.id
     );
 
     if ('ontouchstart' in window) {