Fix covers reloading when removing manga from library

This commit is contained in:
AntsyLich
2026-10-20 04:48:01 +06:00
parent 8b9faa383b
commit a424282840
6 changed files with 13 additions and 21 deletions
+3
View File
@@ -40,6 +40,9 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
- Remove "Custom hardware bitmap threshold" and "Custom display profile" advanced settings ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3786](https://github.com/mihonapp/mihon/pull/3786))
- Remove the "Split tall images" download setting ([@AntsyLich](https://github.com/AntsyLich))
### Fixed
- Fixed covers reloading when removing an entry from the library ([@AntsyLich](https://github.com/AntsyLich))
## [v0.21.2] - 2026-10-13
### Fixed
- Fix long floating point numbers showing up in Comick progress ([@MajorTanya](https://github.com/MajorTanya)) ([#4090](https://github.com/mihonapp/mihon/pull/4090))
@@ -60,9 +60,9 @@ class MangaCoverFetcher(
get() = diskCacheKeyLazy.value
override suspend fun fetch(): FetchResult {
// Use custom cover if exists
// Use custom cover if exists, which only library manga can have
val useCustomCover = options.extras.getOrDefault(USE_CUSTOM_COVER_KEY)
if (useCustomCover) {
if (useCustomCover && isLibraryManga) {
val customCoverFile = customCoverFileLazy.value
if (customCoverFile.exists()) {
return fileLoader(customCoverFile)
@@ -9,7 +9,7 @@ import tachiyomi.domain.manga.model.Manga as DomainManga
class MangaKeyer : Keyer<DomainManga> {
override fun key(data: DomainManga, options: Options): String {
return if (data.hasCustomCover()) {
return if (data.favorite && data.hasCustomCover()) {
"${data.id};${data.coverLastModified}"
} else {
"${data.thumbnailUrl};${data.coverLastModified}"
@@ -21,7 +21,7 @@ class MangaCoverKeyer(
private val coverCache: CoverCache,
) : Keyer<MangaCover> {
override fun key(data: MangaCover, options: Options): String {
return if (coverCache.hasCustomCover(data.mangaId)) {
return if (data.isMangaFavorite && coverCache.hasCustomCover(data.mangaId)) {
"${data.mangaId};${data.lastModified}"
} else {
"${data.url};${data.lastModified}"
@@ -239,11 +239,8 @@ class BrowseSourceViewModel(
fun changeMangaFavorite(manga: Manga) {
appScope.launch {
val update = if (manga.favorite) {
val coverLastModified = manga.removeCovers(coverCache).coverLastModified
MangaUpdate(manga.id) {
favoriteAt = null
if (coverLastModified != manga.coverLastModified) this.coverLastModified = coverLastModified
}
manga.removeCovers(coverCache)
MangaUpdate(manga.id) { favoriteAt = null }
} else {
setMangaDefaultChapterFlags.await(manga)
addTracks.bindEnhancedTrackers(manga, sourceManager.getOrStub(manga.source))
@@ -414,10 +414,7 @@ class MangaViewModel(
if (isFavorited) {
// Remove from library
if (updateManga.awaitUpdateFavorite(manga.id, false)) {
// Remove covers and update last modified in db
if (manga.removeCovers(coverCache) != manga) {
updateManga.awaitUpdateCoverLastModified(manga.id)
}
manga.removeCovers(coverCache)
onRemoved()
}
} else {
@@ -7,15 +7,10 @@ import tachiyomi.domain.manga.model.Manga
import tachiyomi.source.local.image.LocalCoverManager
import tachiyomi.source.local.isLocal
import java.io.InputStream
import kotlin.time.Clock
fun Manga.removeCovers(coverCache: CoverCache): Manga {
if (isLocal()) return this
return if (coverCache.deleteFromCache(this, true) > 0) {
copy(coverLastModified = Clock.System.now())
} else {
this
}
fun Manga.removeCovers(coverCache: CoverCache) {
if (isLocal()) return
coverCache.deleteFromCache(this, true)
}
suspend fun Manga.editCover(