Change repo attribute icons to be localized

This affects anti-features and categories. Reflection diffing has been made more robust in the process with the earlier FileV2 hack removed and better error messages.
This commit is contained in:
Torsten Grote
2022-09-19 14:59:48 -03:00
committed by Hans-Christoph Steiner
parent 3eca9402fe
commit e86063937a
17 changed files with 278 additions and 123 deletions

View File

@@ -237,7 +237,7 @@ internal fun MirrorV2.toMirror(repoId: Long) = Mirror(
* An attribute belonging to a [Repository].
*/
public abstract class RepoAttribute {
public abstract val icon: FileV2?
public abstract val icon: LocalizedFileV2
internal abstract val name: LocalizedTextV2
internal abstract val description: LocalizedTextV2
@@ -264,7 +264,7 @@ public abstract class RepoAttribute {
public data class AntiFeature internal constructor(
internal val repoId: Long,
internal val id: String,
@Embedded(prefix = "icon_") public override val icon: FileV2? = null,
override val icon: LocalizedFileV2,
override val name: LocalizedTextV2,
override val description: LocalizedTextV2,
) : RepoAttribute() {
@@ -299,7 +299,7 @@ internal fun Map<String, AntiFeatureV2>.toRepoAntiFeatures(repoId: Long) = map {
public data class Category internal constructor(
internal val repoId: Long,
public val id: String,
@Embedded(prefix = "icon_") public override val icon: FileV2? = null,
override val icon: LocalizedFileV2,
override val name: LocalizedTextV2,
override val description: LocalizedTextV2,
) : RepoAttribute() {
@@ -334,7 +334,7 @@ internal fun Map<String, CategoryV2>.toRepoCategories(repoId: Long) = map {
public data class ReleaseChannel(
internal val repoId: Long,
internal val id: String,
@Embedded(prefix = "icon_") public override val icon: FileV2? = null,
override val icon: LocalizedFileV2 = emptyMap(),
override val name: LocalizedTextV2,
override val description: LocalizedTextV2,
) : RepoAttribute() {

View File

@@ -272,7 +272,7 @@ internal interface RepositoryDaoInt : RepositoryDao {
jsonObjectKey = "antiFeatures",
itemList = repo.antiFeatures,
itemFinder = { key, item -> item.id == key },
newItem = { key -> AntiFeature(repoId, key, null, emptyMap(), emptyMap()) },
newItem = { key -> AntiFeature(repoId, key, emptyMap(), emptyMap(), emptyMap()) },
deleteAll = { deleteAntiFeatures(repoId) },
deleteOne = { key -> deleteAntiFeature(repoId, key) },
insertReplace = { list -> insertAntiFeatures(list) },
@@ -283,7 +283,7 @@ internal interface RepositoryDaoInt : RepositoryDao {
jsonObjectKey = "categories",
itemList = repo.categories,
itemFinder = { key, item -> item.id == key },
newItem = { key -> Category(repoId, key, null, emptyMap(), emptyMap()) },
newItem = { key -> Category(repoId, key, emptyMap(), emptyMap(), emptyMap()) },
deleteAll = { deleteCategories(repoId) },
deleteOne = { key -> deleteCategory(repoId, key) },
insertReplace = { list -> insertCategories(list) },
@@ -294,7 +294,7 @@ internal interface RepositoryDaoInt : RepositoryDao {
jsonObjectKey = "releaseChannels",
itemList = repo.releaseChannels,
itemFinder = { key, item -> item.id == key },
newItem = { key -> ReleaseChannel(repoId, key, null, emptyMap(), emptyMap()) },
newItem = { key -> ReleaseChannel(repoId, key, emptyMap(), emptyMap(), emptyMap()) },
deleteAll = { deleteReleaseChannels(repoId) },
deleteOne = { key -> deleteReleaseChannel(repoId, key) },
insertReplace = { list -> insertReleaseChannels(list) },