Misc small fixes
This commit is contained in:
@@ -7,6 +7,8 @@ import android.webkit.MimeTypeMap
|
||||
import androidx.collection.ArraySet
|
||||
import androidx.core.net.toFile
|
||||
import androidx.core.net.toUri
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.koitharu.kotatsu.core.model.*
|
||||
import org.koitharu.kotatsu.core.parser.MangaRepository
|
||||
import org.koitharu.kotatsu.local.data.CbzFilter
|
||||
@@ -127,14 +129,16 @@ class LocalMangaRepository(private val context: Context) : MangaRepository {
|
||||
)
|
||||
}
|
||||
|
||||
fun getRemoteManga(localManga: Manga): Manga? {
|
||||
suspend fun getRemoteManga(localManga: Manga): Manga? {
|
||||
val file = runCatching {
|
||||
Uri.parse(localManga.url).toFile()
|
||||
}.getOrNull() ?: return null
|
||||
val zip = ZipFile(file)
|
||||
val entry = zip.getEntry(MangaZip.INDEX_ENTRY)
|
||||
val index = entry?.let(zip::readText)?.let(::MangaIndex) ?: return null
|
||||
return index.getMangaInfo()
|
||||
return withContext(Dispatchers.IO) {
|
||||
val zip = ZipFile(file)
|
||||
val entry = zip.getEntry(MangaZip.INDEX_ENTRY)
|
||||
val index = entry?.let(zip::readText)?.let(::MangaIndex) ?: return@withContext null
|
||||
index.getMangaInfo()
|
||||
}
|
||||
}
|
||||
|
||||
private fun zipUri(file: File, entryName: String) =
|
||||
|
||||
@@ -99,6 +99,7 @@ class LocalListViewModel(
|
||||
runCatching {
|
||||
historyRepository.deleteOrSwap(manga, original)
|
||||
}
|
||||
mangaList.value = mangaList.value?.filterNot { it.id == manga.id }
|
||||
}
|
||||
shortcutsRepository.updateShortcuts()
|
||||
onMangaRemoved.call(manga)
|
||||
|
||||
@@ -28,13 +28,8 @@ class TrackingRepository(
|
||||
}
|
||||
val tracks = db.tracksDao.findAll().groupBy { it.mangaId }
|
||||
return mangaList
|
||||
.mapNotNull {
|
||||
if (it.source == MangaSource.LOCAL) {
|
||||
localMangaRepository.getRemoteManga(it)
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}.distinctBy { it.id }
|
||||
.filterNot { it.source == MangaSource.LOCAL }
|
||||
.distinctBy { it.id }
|
||||
.map { manga ->
|
||||
val track = tracks[manga.id]?.singleOrNull()
|
||||
MangaTracking(
|
||||
|
||||
Reference in New Issue
Block a user