From f097d71237954c735b8bce8de36f57c7e769e3e7 Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Sun, 26 Jul 2026 01:59:32 +0200 Subject: [PATCH] Name a translation after its dialect addTranslation set the MantraTranslationArtifactVersion name to the source artifact's name; use the selected dialect's name instead (visibility and license still inherit from the artifact). Add a getDialectById query to look the dialect up by id. Co-Authored-By: Claude Opus 4.8 --- .../press/mantra/compose/database/dao/MantraDialectDao.kt | 3 +++ .../compose/database/repository/DatabaseMantraRepository.kt | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/press/mantra/compose/database/dao/MantraDialectDao.kt b/composeApp/src/commonMain/kotlin/press/mantra/compose/database/dao/MantraDialectDao.kt index 898e88a2..26922127 100644 --- a/composeApp/src/commonMain/kotlin/press/mantra/compose/database/dao/MantraDialectDao.kt +++ b/composeApp/src/commonMain/kotlin/press/mantra/compose/database/dao/MantraDialectDao.kt @@ -14,4 +14,7 @@ interface MantraDialectDao { @Query("SELECT * FROM MantraDialect WHERE chatRoomId = :chatRoomId ORDER BY name") suspend fun getDialectsByChatRoomId(chatRoomId: String): List + + @Query("SELECT * FROM MantraDialect WHERE id = :id") + suspend fun getDialectById(id: String): MantraDialect? } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/press/mantra/compose/database/repository/DatabaseMantraRepository.kt b/composeApp/src/commonMain/kotlin/press/mantra/compose/database/repository/DatabaseMantraRepository.kt index 790ba964..30e085a7 100644 --- a/composeApp/src/commonMain/kotlin/press/mantra/compose/database/repository/DatabaseMantraRepository.kt +++ b/composeApp/src/commonMain/kotlin/press/mantra/compose/database/repository/DatabaseMantraRepository.kt @@ -54,12 +54,14 @@ class DatabaseMantraRepository( val version = database.mantraArtifactVersionDao() .getArtifactVersionsByArtifactId(artifactId) .firstOrNull() ?: return null + val dialect = database.mantraDialectDao().getDialectById(dialectId) ?: return null - // The translation inherits the source artifact's name/visibility/license. + // The translation is named after its dialect, and inherits the source + // artifact's visibility/license. val translationVersionTemplate = TranslationArtifactVersionEvent.build( artifactVersionId = version.id, dialectId = dialectId, - name = artifact.name, + name = dialect.name, visibility = artifact.visibility, license = artifact.license, )