Mercurial > hg > ugly-duckling
changeset 463:c9c6b01e9b4f
Add function for getting the rood audio item from different item types.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Fri, 30 Jun 2017 13:59:51 +0100 |
parents | 2624bb55dbf6 |
children | 50f61d1945db |
files | src/app/analysis-item/AnalysisItem.ts |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/app/analysis-item/AnalysisItem.ts Fri Jun 30 13:59:21 2017 +0100 +++ b/src/app/analysis-item/AnalysisItem.ts Fri Jun 30 13:59:51 2017 +0100 @@ -56,15 +56,19 @@ downcast.collected != null; } +export function getRootAudioItem(item: Item): RootAudioItem { + if (isPendingRootAudioItem(item)) { + return item; + } + if (isPendingAnalysisItem(item)) { + return item.parent; + } + throw new Error('Invalid item.'); +} + // these should probably be actual concrete types with their own getUri methods export function getRootUri(item: Item): string { - if (isPendingRootAudioItem(item)) { - return item.uri; - } - if (isPendingAnalysisItem(item)) { - return item.parent.uri; - } - throw new Error('Invalid item: No URI property set.'); + return getRootAudioItem(item).uri; } export function createExtractionRequest(item: AnalysisItem): SimpleRequest {