Remove SourceData and use StubSource directly for database (#9429)

This commit is contained in:
Andreas
2023-05-03 16:33:05 +02:00
committed by GitHub
parent b328f0e344
commit f63573f25f
12 changed files with 81 additions and 97 deletions

View File

@@ -1,10 +0,0 @@
package tachiyomi.domain.source.model
data class SourceData(
val id: Long,
val lang: String,
val name: String,
) {
val isMissingInfo: Boolean = name.isBlank() || lang.isBlank()
}

View File

@@ -7,13 +7,13 @@ import eu.kanade.tachiyomi.source.model.SManga
import rx.Observable
@Suppress("OverridingDeprecatedMember")
class StubSource(private val sourceData: SourceData) : Source {
class StubSource(
override val id: Long,
override val name: String,
override val lang: String,
) : Source {
override val id: Long = sourceData.id
override val name: String = sourceData.name.ifBlank { id.toString() }
override val lang: String = sourceData.lang
val isInvalid: Boolean = name.isBlank() || lang.isBlank()
override suspend fun getMangaDetails(manga: SManga): SManga {
throw SourceNotInstalledException()
@@ -43,7 +43,7 @@ class StubSource(private val sourceData: SourceData) : Source {
}
override fun toString(): String {
return if (sourceData.isMissingInfo.not()) "$name (${lang.uppercase()})" else id.toString()
return if (isInvalid.not()) "$name (${lang.uppercase()})" else id.toString()
}
}

View File

@@ -1,12 +0,0 @@
package tachiyomi.domain.source.repository
import kotlinx.coroutines.flow.Flow
import tachiyomi.domain.source.model.SourceData
interface SourceDataRepository {
fun subscribeAll(): Flow<List<SourceData>>
suspend fun getSourceData(id: Long): SourceData?
suspend fun upsertSourceData(id: Long, lang: String, name: String)
}

View File

@@ -0,0 +1,12 @@
package tachiyomi.domain.source.repository
import kotlinx.coroutines.flow.Flow
import tachiyomi.domain.source.model.StubSource
interface StubSourceRepository {
fun subscribeAll(): Flow<List<StubSource>>
suspend fun getStubSource(id: Long): StubSource?
suspend fun upsertStubSource(id: Long, lang: String, name: String)
}