mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-23 03:28:55 +02:00
Remove SourceData and use StubSource directly for database (#9429)
This commit is contained in:
@@ -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()
|
||||
}
|
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
}
|
@@ -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)
|
||||
}
|
Reference in New Issue
Block a user