Little cleanup for stub source (#7519)

* Little cleanup for stub source

Fixes instances where name shows up blank for stub sources

* Review Changes

Co-authored-by: Andreas <andreas.everos@gmail.com>

Co-authored-by: Andreas <andreas.everos@gmail.com>
This commit is contained in:
AntsyLich 2022-07-15 03:17:31 +06:00 committed by GitHub
parent 4684797dfb
commit 902bb35ba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -4,4 +4,7 @@ data class SourceData(
val id: Long, val id: Long,
val lang: String, val lang: String,
val name: String, val name: String,
) ) {
val isMissingInfo: Boolean = name.isBlank() || lang.isBlank()
}

View File

@ -108,12 +108,12 @@ class SourceManager(private val context: Context) {
@Suppress("OverridingDeprecatedMember") @Suppress("OverridingDeprecatedMember")
open inner class StubSource(val sourceData: SourceData) : Source { open inner class StubSource(val sourceData: SourceData) : Source {
override val name: String = sourceData.name override val id: Long = sourceData.id
override val name: String = sourceData.name.ifBlank { id.toString() }
override val lang: String = sourceData.lang override val lang: String = sourceData.lang
override val id: Long = sourceData.id
override suspend fun getMangaDetails(manga: MangaInfo): MangaInfo { override suspend fun getMangaDetails(manga: MangaInfo): MangaInfo {
throw getSourceNotInstalledException() throw getSourceNotInstalledException()
} }
@ -139,10 +139,7 @@ class SourceManager(private val context: Context) {
} }
override fun toString(): String { override fun toString(): String {
if (name.isNotBlank() && lang.isNotBlank()) { return if (sourceData.isMissingInfo.not()) "$name (${lang.uppercase()})" else id.toString()
return "$name (${lang.uppercase()})"
}
return id.toString()
} }
fun getSourceNotInstalledException(): SourceNotInstalledException { fun getSourceNotInstalledException(): SourceNotInstalledException {