# HG changeset patch # User Lucas Thompson # Date 1496153252 -3600 # Node ID f12a12ce9de0efafe04d5c2efdae7cbfd5e3beeb # Parent 1ad3c86fd1f73a0fc1f21e2dbd0e3c7b07c4bdcf Change AnalysisItem type slightly to actually contain the feature data. Improve type guards a tad. diff -r 1ad3c86fd1f7 -r f12a12ce9de0 src/app/analysis-item/analysis-item.component.ts --- a/src/app/analysis-item/analysis-item.component.ts Tue May 30 15:06:37 2017 +0100 +++ b/src/app/analysis-item/analysis-item.component.ts Tue May 30 15:07:32 2017 +0100 @@ -9,7 +9,10 @@ } from '@angular/core'; import {naivePagingMapper} from '../visualisations/WavesJunk'; import {OnSeekHandler, TimePixelMapper} from '../playhead/PlayHeadHelpers'; -import {HigherLevelFeatureShape} from '../visualisations/FeatureUtilities'; +import { + HigherLevelFeatureShape, + KnownShapedFeature +} from '../visualisations/FeatureUtilities'; export interface Item { id: string; @@ -31,12 +34,14 @@ extractorKey: string; } -export interface AnalysisItem extends PendingAnalysisItem { - kind: HigherLevelFeatureShape; +export type AnalysisItem = PendingAnalysisItem & KnownShapedFeature; + +export function isItem(item: Item): item is Item { + return item.id != null && item.hasSharedTimeline != null; } export function isPendingRootAudioItem(item: Item): item is PendingRootAudioItem { - return typeof (item as RootAudioItem).uri === 'string'; + return isItem(item) && typeof (item as RootAudioItem).uri === 'string'; } export function isRootAudioItem(item: Item): item is RootAudioItem { @@ -52,7 +57,9 @@ export function isAnalysisItem(item: Item): item is AnalysisItem { const downcast = (item as AnalysisItem); - return isPendingAnalysisItem(item) && downcast.kind != null; + return isPendingAnalysisItem(item) && + downcast.shape != null && + downcast.collected != null; } // these should probably be actual concrete types with their own getUri methods @@ -97,4 +104,9 @@ isAudioItem(): boolean { return isRootAudioItem(this.item); } + + getFeatureShape(): HigherLevelFeatureShape | null { + return !isPendingRootAudioItem(this.item) && + isAnalysisItem(this.item) ? this.item.shape : null; + } }