annotate src/app/notebook-feed/notebook-feed.component.ts @ 282:5ab9e6132424

Create independent Timeline for each rootAudioUri, no idea how this was working before. Not sure if these belong here or in the application state, but this is better than before.
author Lucas Thompson <dev@lucas.im>
date Thu, 04 May 2017 15:21:52 +0100
parents 53ea6406d601
children 2d7da410ba46
rev   line source
dev@171 1 /**
dev@171 2 * Created by lucast on 21/03/2017.
dev@171 3 */
dev@232 4 import {
dev@232 5 ChangeDetectionStrategy,
dev@232 6 Component,
dev@232 7 Input
dev@236 8 } from '@angular/core';
dev@178 9 import Waves from 'waves-ui';
dev@236 10 import {AnalysisItem} from '../analysis-item/analysis-item.component';
dev@171 11
dev@171 12 @Component({
dev@171 13 selector: 'ugly-notebook-feed',
dev@171 14 templateUrl: './notebook-feed.component.html',
dev@232 15 styleUrls: ['./notebook-feed.component.css'],
dev@232 16 changeDetection: ChangeDetectionStrategy.OnPush
dev@171 17 })
dev@171 18 export class NotebookFeedComponent {
dev@201 19 @Input() analyses: AnalysisItem[];
dev@201 20 @Input() set rootAudioUri(uri: string) {
dev@201 21 this._rootAudioUri = uri;
dev@171 22 }
dev@171 23
dev@201 24 get rootAudioUri(): string {
dev@201 25 return this._rootAudioUri;
dev@171 26 }
dev@201 27 private _rootAudioUri: string;
dev@282 28 private timelines: Map<string, Timeline>;
dev@181 29
dev@181 30 constructor() {
dev@282 31 this.timelines = new Map();
dev@282 32 }
dev@282 33
dev@282 34 getOrCreateTimeline(item: AnalysisItem): Timeline | void {
dev@282 35 if (!item.hasSharedTimeline) {
dev@282 36 return;
dev@282 37 }
dev@282 38
dev@282 39 if (this.timelines.has(item.rootAudioUri)) {
dev@282 40 return this.timelines.get(item.rootAudioUri);
dev@282 41 } else {
dev@282 42 const timeline = new Waves.core.Timeline();
dev@282 43 this.timelines.set(item.rootAudioUri, timeline);
dev@282 44 return timeline;
dev@282 45 }
dev@181 46 }
dev@171 47 }