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 <noreply@anthropic.com>
This commit is contained in:
Kgothatso Ngako
2026-07-26 01:59:32 +02:00
parent 99f99fa959
commit f097d71237
2 changed files with 7 additions and 2 deletions

View File

@@ -14,4 +14,7 @@ interface MantraDialectDao {
@Query("SELECT * FROM MantraDialect WHERE chatRoomId = :chatRoomId ORDER BY name")
suspend fun getDialectsByChatRoomId(chatRoomId: String): List<MantraDialect>
@Query("SELECT * FROM MantraDialect WHERE id = :id")
suspend fun getDialectById(id: String): MantraDialect?
}

View File

@@ -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,
)