Skip to content

Commit

Permalink
Merge pull request #535 from cinadia/534-do-not-allow-the-creation-of…
Browse files Browse the repository at this point in the history
…-new-phrases-with-recent-ceategory

Prevents adding RECENTS phrases to database
  • Loading branch information
PaulKlauser authored Jun 4, 2024
2 parents 34ecbdf + edd8304 commit 4212039
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions app/src/main/java/com/willowtree/vocable/PhrasesUseCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,19 @@ class PhrasesUseCase(
}

override suspend fun addPhrase(localizedUtterance: LocalesWithText, parentCategoryId: String) {
storedPhrasesRepository.addPhrase(PhraseDto(
phraseId = uuidProvider.randomUUIDString(),
parentCategoryId = parentCategoryId,
creationDate = dateProvider.currentTimeMillis(),
lastSpokenDate = null,
localizedUtterance = localizedUtterance,
sortOrder = legacyPhrasesRepository.getPhrasesForCategory(parentCategoryId).size
))
if (parentCategoryId != PresetCategories.RECENTS.id) {
storedPhrasesRepository.addPhrase(PhraseDto(
phraseId = uuidProvider.randomUUIDString(),
parentCategoryId = parentCategoryId,
creationDate = dateProvider.currentTimeMillis(),
lastSpokenDate = null,
localizedUtterance = localizedUtterance,
sortOrder = legacyPhrasesRepository.getPhrasesForCategory(parentCategoryId).size
))
} else {
throw Exception("The 'Recents' category is not a true category -" +
" it is a filter applied to true categories. Therefore, saving phrases from " +
"the Recents 'category' is not supported.")
}
}
}

0 comments on commit 4212039

Please sign in to comment.