Skip to content

Commit

Permalink
Fix downloads being "lost" when switching manga title to alt title
Browse files Browse the repository at this point in the history
  • Loading branch information
nonproto committed Feb 22, 2024
1 parent 1c70fad commit 3e4f62f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class DownloadCache(
/** Searches a manga list and matches the given mangakey and source key */
private fun findManga(mangaList: List<Manga>, mangaKey: String, sourceKey: Long): Manga? {
return mangaList.find {
DiskUtil.buildValidFilename(it.title).lowercase(Locale.US) ==
DiskUtil.buildValidFilename(it.originalTitle).lowercase(Locale.US) ==
mangaKey.lowercase(Locale.US) && it.source == sourceKey
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ class MangaDetailPresenter(
private val _currentManga = MutableStateFlow<Manga?>(null)
val manga: StateFlow<Manga?> = _currentManga.asStateFlow()

val downloadsScope = presenterScope

private fun currentManga(): Manga {
if (_currentManga.value == null) {
val dbManga = db.getManga(mangaId).executeAsBlocking()
Expand Down Expand Up @@ -168,12 +166,9 @@ class MangaDetailPresenter(
_currentManga.value = dbManga
val validMergeTypes =
when (sourceManager.komga.hasCredentials()) {
true -> MergeType.values().toList().toPersistentList()
true -> MergeType.entries.toPersistentList()
false ->
MergeType.values()
.toList()
.filterNot { it == MergeType.Komga }
.toPersistentList()
MergeType.entries.filterNot { it == MergeType.Komga }.toPersistentList()
}
_generalState.value =
MangaConstants.MangaScreenGeneralState(
Expand Down Expand Up @@ -1908,7 +1903,7 @@ class MangaDetailPresenter(
}

// This is already filtered before reaching here, so directly update the chapters
fun onUpdateManga(mangaId: Long?) {
private fun onUpdateManga(mangaId: Long?) {
updateChapterFlows()
}

Expand Down Expand Up @@ -1959,7 +1954,7 @@ class MangaDetailPresenter(
}

// callback from Downloader
fun updateDownloadState(download: Download) {
private fun updateDownloadState(download: Download) {
presenterScope.launchIO {
val currentChapters = generalState.value.activeChapters
val index = currentChapters.indexOfFirst { it.chapter.id == download.chapter.id }
Expand All @@ -1980,10 +1975,6 @@ class MangaDetailPresenter(
}
}

/* override fun updateDownloads() {
presenterScope.launchIO { updateChapterFlows() }
}*/

fun getChapterUrl(chapter: SimpleChapter): String {
return chapter.getHttpSource(sourceManager).getChapterUrl(chapter)
}
Expand Down

0 comments on commit 3e4f62f

Please sign in to comment.