From ac597d39e63b1e3fe3e9347aa4bcd0fac0c9c810 Mon Sep 17 00:00:00 2001 From: Tony <34975907+AnonymousWalker@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:32:35 -0400 Subject: [PATCH] Fall back to source audio inside project directory when applicable (#1186) * picks up source audio in project dir if applicable * add note --- .../jvm/workbookapp/ui/viewmodel/ChunkingViewModel.kt | 9 ++++++--- .../jvm/workbookapp/ui/viewmodel/ConsumeViewModel.kt | 1 + .../workbookapp/ui/viewmodel/TranslationViewModel2.kt | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ChunkingViewModel.kt b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ChunkingViewModel.kt index 61a93e2e81..29dc89fe41 100644 --- a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ChunkingViewModel.kt +++ b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ChunkingViewModel.kt @@ -148,10 +148,13 @@ class ChunkingViewModel : ViewModel(), IMarkerViewModel { private fun initializeSourceAudio(chapter: Int): Maybe { return Maybe.fromCallable { val workbook = workbookDataStore.workbook - ChunkAudioUseCase(directoryProvider, workbook.projectFilesAccessor) - .copySourceAudioToProject(sourceAudio.file) + workbook.sourceAudioAccessor.getUserMarkedChapter(chapter, workbook.target) // this first call is intentional. See https://github.com/Bible-Translation-Tools/Orature/pull/1186 + ?: let { + ChunkAudioUseCase(directoryProvider, workbook.projectFilesAccessor) + .copySourceAudioToProject(sourceAudio.file) - workbook.sourceAudioAccessor.getUserMarkedChapter(chapter, workbook.target) + workbook.sourceAudioAccessor.getUserMarkedChapter(chapter, workbook.target) + } } } diff --git a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ConsumeViewModel.kt b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ConsumeViewModel.kt index e79343f688..1b57822129 100644 --- a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ConsumeViewModel.kt +++ b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/ConsumeViewModel.kt @@ -99,6 +99,7 @@ class ConsumeViewModel : ViewModel(), IMarkerViewModel { Maybe .fromCallable { wb.sourceAudioAccessor.getChapter(chapter.sort, wb.target) + ?: wb.sourceAudioAccessor.getUserMarkedChapter(chapter.sort, wb.target) } .subscribeOn(Schedulers.io()) .observeOnFx() diff --git a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/TranslationViewModel2.kt b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/TranslationViewModel2.kt index ed5a2a3fa9..7fb7a2a530 100644 --- a/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/TranslationViewModel2.kt +++ b/jvm/workbookapp/src/main/kotlin/org/wycliffeassociates/otter/jvm/workbookapp/ui/viewmodel/TranslationViewModel2.kt @@ -267,6 +267,7 @@ class TranslationViewModel2 : ViewModel() { Maybe .fromCallable { wb.sourceAudioAccessor.getChapter(chapter.sort, wb.target) + ?: wb.sourceAudioAccessor.getUserMarkedChapter(chapter.sort, wb.target) } .subscribeOn(Schedulers.io()) .observeOnFx()