From 8749be518f8fb7f278f35f110df6c1d5b4b2508e Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 5 Nov 2022 10:37:32 -0400 Subject: [PATCH] Adjust read next history logic Closes #8454 --- .../java/eu/kanade/domain/DomainModule.kt | 12 ++-- .../history/interactor/DeleteAllHistory.kt | 12 ---- .../domain/history/interactor/GetHistory.kt | 1 + .../history/interactor/GetNextChapters.kt | 52 ++++++++++++++ .../interactor/GetNextUnreadChapters.kt | 33 --------- ...{RemoveHistoryById.kt => RemoveHistory.kt} | 10 ++- .../interactor/RemoveHistoryByMangaId.kt | 12 ---- .../presentation/history/HistoryScreen.kt | 6 +- .../history/components/HistoryToolbar.kt | 4 +- .../presentation/updates/UpdatesScreen.kt | 8 +-- .../presentation/updates/UpdatesState.kt | 4 +- .../presentation/updates/UpdatesUiItem.kt | 2 +- .../{recent => }/history/HistoryController.kt | 2 +- .../{recent => }/history/HistoryPresenter.kt | 70 +++++++++---------- .../tachiyomi/ui/library/LibraryPresenter.kt | 6 +- .../kanade/tachiyomi/ui/main/MainActivity.kt | 4 +- .../tachiyomi/ui/manga/MangaController.kt | 4 +- .../tachiyomi/ui/reader/ReaderPresenter.kt | 6 +- .../{recent => }/updates/UpdatesController.kt | 3 +- .../{recent => }/updates/UpdatesPresenter.kt | 8 +-- 20 files changed, 129 insertions(+), 130 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/domain/history/interactor/DeleteAllHistory.kt create mode 100644 app/src/main/java/eu/kanade/domain/history/interactor/GetNextChapters.kt delete mode 100644 app/src/main/java/eu/kanade/domain/history/interactor/GetNextUnreadChapters.kt rename app/src/main/java/eu/kanade/domain/history/interactor/{RemoveHistoryById.kt => RemoveHistory.kt} (61%) delete mode 100644 app/src/main/java/eu/kanade/domain/history/interactor/RemoveHistoryByMangaId.kt rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent => }/history/HistoryController.kt (95%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent => }/history/HistoryPresenter.kt (79%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent => }/updates/UpdatesController.kt (96%) rename app/src/main/java/eu/kanade/tachiyomi/ui/{recent => }/updates/UpdatesPresenter.kt (99%) diff --git a/app/src/main/java/eu/kanade/domain/DomainModule.kt b/app/src/main/java/eu/kanade/domain/DomainModule.kt index 0240a4027..075b50e7d 100644 --- a/app/src/main/java/eu/kanade/domain/DomainModule.kt +++ b/app/src/main/java/eu/kanade/domain/DomainModule.kt @@ -32,11 +32,9 @@ import eu.kanade.domain.download.interactor.DeleteDownload import eu.kanade.domain.extension.interactor.GetExtensionLanguages import eu.kanade.domain.extension.interactor.GetExtensionSources import eu.kanade.domain.extension.interactor.GetExtensionsByType -import eu.kanade.domain.history.interactor.DeleteAllHistory import eu.kanade.domain.history.interactor.GetHistory -import eu.kanade.domain.history.interactor.GetNextUnreadChapters -import eu.kanade.domain.history.interactor.RemoveHistoryById -import eu.kanade.domain.history.interactor.RemoveHistoryByMangaId +import eu.kanade.domain.history.interactor.GetNextChapters +import eu.kanade.domain.history.interactor.RemoveHistory import eu.kanade.domain.history.interactor.UpsertHistory import eu.kanade.domain.history.repository.HistoryRepository import eu.kanade.domain.manga.interactor.GetDuplicateLibraryManga @@ -94,7 +92,7 @@ class DomainModule : InjektModule { addFactory { GetLibraryManga(get()) } addFactory { GetMangaWithChapters(get(), get()) } addFactory { GetManga(get()) } - addFactory { GetNextUnreadChapters(get(), get(), get()) } + addFactory { GetNextChapters(get(), get(), get()) } addFactory { ResetViewerFlags(get()) } addFactory { SetMangaChapterFlags(get()) } addFactory { SetMangaDefaultChapterFlags(get(), get(), get()) } @@ -119,11 +117,9 @@ class DomainModule : InjektModule { addFactory { SyncChaptersWithTrackServiceTwoWay(get(), get()) } addSingletonFactory { HistoryRepositoryImpl(get()) } - addFactory { DeleteAllHistory(get()) } addFactory { GetHistory(get()) } addFactory { UpsertHistory(get()) } - addFactory { RemoveHistoryById(get()) } - addFactory { RemoveHistoryByMangaId(get()) } + addFactory { RemoveHistory(get()) } addFactory { DeleteDownload(get(), get()) } diff --git a/app/src/main/java/eu/kanade/domain/history/interactor/DeleteAllHistory.kt b/app/src/main/java/eu/kanade/domain/history/interactor/DeleteAllHistory.kt deleted file mode 100644 index 292cf9e42..000000000 --- a/app/src/main/java/eu/kanade/domain/history/interactor/DeleteAllHistory.kt +++ /dev/null @@ -1,12 +0,0 @@ -package eu.kanade.domain.history.interactor - -import eu.kanade.domain.history.repository.HistoryRepository - -class DeleteAllHistory( - private val repository: HistoryRepository, -) { - - suspend fun await(): Boolean { - return repository.deleteAllHistory() - } -} diff --git a/app/src/main/java/eu/kanade/domain/history/interactor/GetHistory.kt b/app/src/main/java/eu/kanade/domain/history/interactor/GetHistory.kt index 482995f25..cf1d00ed2 100644 --- a/app/src/main/java/eu/kanade/domain/history/interactor/GetHistory.kt +++ b/app/src/main/java/eu/kanade/domain/history/interactor/GetHistory.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.flow.Flow class GetHistory( private val repository: HistoryRepository, ) { + fun subscribe(query: String): Flow> { return repository.getHistory(query) } diff --git a/app/src/main/java/eu/kanade/domain/history/interactor/GetNextChapters.kt b/app/src/main/java/eu/kanade/domain/history/interactor/GetNextChapters.kt new file mode 100644 index 000000000..dadeb3546 --- /dev/null +++ b/app/src/main/java/eu/kanade/domain/history/interactor/GetNextChapters.kt @@ -0,0 +1,52 @@ +package eu.kanade.domain.history.interactor + +import eu.kanade.domain.chapter.interactor.GetChapterByMangaId +import eu.kanade.domain.chapter.model.Chapter +import eu.kanade.domain.history.repository.HistoryRepository +import eu.kanade.domain.manga.interactor.GetManga +import eu.kanade.tachiyomi.util.chapter.getChapterSort +import kotlin.math.max + +class GetNextChapters( + private val getChapterByMangaId: GetChapterByMangaId, + private val getManga: GetManga, + private val historyRepository: HistoryRepository, +) { + + suspend fun await(onlyUnread: Boolean = true): List { + val history = historyRepository.getLastHistory() ?: return emptyList() + return await(history.mangaId, history.chapterId, onlyUnread) + } + + suspend fun await(mangaId: Long, onlyUnread: Boolean = true): List { + val manga = getManga.await(mangaId) ?: return emptyList() + val chapters = getChapterByMangaId.await(mangaId) + .sortedWith(getChapterSort(manga, sortDescending = false)) + + return if (onlyUnread) { + chapters.filterNot { it.read } + } else { + chapters + } + } + + suspend fun await(mangaId: Long, fromChapterId: Long, onlyUnread: Boolean = true): List { + val chapters = await(mangaId, onlyUnread) + val currChapterIndex = chapters.indexOfFirst { it.id == fromChapterId } + val nextChapters = chapters.subList(max(0, currChapterIndex), chapters.size) + + if (onlyUnread) { + return nextChapters + } + + // The "next chapter" is either: + // - The current chapter if it isn't completely read + // - The chapters after the current chapter if the current one is completely read + val fromChapter = chapters.getOrNull(currChapterIndex) + return if (fromChapter != null && !fromChapter.read) { + nextChapters + } else { + nextChapters.drop(1) + } + } +} diff --git a/app/src/main/java/eu/kanade/domain/history/interactor/GetNextUnreadChapters.kt b/app/src/main/java/eu/kanade/domain/history/interactor/GetNextUnreadChapters.kt deleted file mode 100644 index 8c61eaca7..000000000 --- a/app/src/main/java/eu/kanade/domain/history/interactor/GetNextUnreadChapters.kt +++ /dev/null @@ -1,33 +0,0 @@ -package eu.kanade.domain.history.interactor - -import eu.kanade.domain.chapter.interactor.GetChapterByMangaId -import eu.kanade.domain.chapter.model.Chapter -import eu.kanade.domain.history.repository.HistoryRepository -import eu.kanade.domain.manga.interactor.GetManga -import eu.kanade.tachiyomi.util.chapter.getChapterSort -import kotlin.math.max - -class GetNextUnreadChapters( - private val getChapterByMangaId: GetChapterByMangaId, - private val getManga: GetManga, - private val historyRepository: HistoryRepository, -) { - - suspend fun await(): Chapter? { - val history = historyRepository.getLastHistory() ?: return null - return await(history.mangaId, history.chapterId).firstOrNull() - } - - suspend fun await(mangaId: Long): List { - val manga = getManga.await(mangaId) ?: return emptyList() - return getChapterByMangaId.await(mangaId) - .sortedWith(getChapterSort(manga, sortDescending = false)) - .filterNot { it.read } - } - - suspend fun await(mangaId: Long, fromChapterId: Long): List { - val unreadChapters = await(mangaId) - val currChapterIndex = unreadChapters.indexOfFirst { it.id == fromChapterId } - return unreadChapters.subList(max(0, currChapterIndex), unreadChapters.size) - } -} diff --git a/app/src/main/java/eu/kanade/domain/history/interactor/RemoveHistoryById.kt b/app/src/main/java/eu/kanade/domain/history/interactor/RemoveHistory.kt similarity index 61% rename from app/src/main/java/eu/kanade/domain/history/interactor/RemoveHistoryById.kt rename to app/src/main/java/eu/kanade/domain/history/interactor/RemoveHistory.kt index 4eb15568c..a2099a1a8 100644 --- a/app/src/main/java/eu/kanade/domain/history/interactor/RemoveHistoryById.kt +++ b/app/src/main/java/eu/kanade/domain/history/interactor/RemoveHistory.kt @@ -3,11 +3,19 @@ package eu.kanade.domain.history.interactor import eu.kanade.domain.history.model.HistoryWithRelations import eu.kanade.domain.history.repository.HistoryRepository -class RemoveHistoryById( +class RemoveHistory( private val repository: HistoryRepository, ) { + suspend fun awaitAll(): Boolean { + return repository.deleteAllHistory() + } + suspend fun await(history: HistoryWithRelations) { repository.resetHistory(history.id) } + + suspend fun await(mangaId: Long) { + repository.resetHistoryByMangaId(mangaId) + } } diff --git a/app/src/main/java/eu/kanade/domain/history/interactor/RemoveHistoryByMangaId.kt b/app/src/main/java/eu/kanade/domain/history/interactor/RemoveHistoryByMangaId.kt deleted file mode 100644 index 4c3558456..000000000 --- a/app/src/main/java/eu/kanade/domain/history/interactor/RemoveHistoryByMangaId.kt +++ /dev/null @@ -1,12 +0,0 @@ -package eu.kanade.domain.history.interactor - -import eu.kanade.domain.history.repository.HistoryRepository - -class RemoveHistoryByMangaId( - private val repository: HistoryRepository, -) { - - suspend fun await(mangaId: Long) { - repository.resetHistoryByMangaId(mangaId) - } -} diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt index 2e72570d9..256f3dca2 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt @@ -16,10 +16,10 @@ import eu.kanade.presentation.history.components.HistoryDeleteAllDialog import eu.kanade.presentation.history.components.HistoryDeleteDialog import eu.kanade.presentation.history.components.HistoryToolbar import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.ui.history.HistoryPresenter +import eu.kanade.tachiyomi.ui.history.HistoryPresenter.Dialog import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.reader.ReaderActivity -import eu.kanade.tachiyomi.ui.recent.history.HistoryPresenter -import eu.kanade.tachiyomi.ui.recent.history.HistoryPresenter.Dialog import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.widget.TachiyomiBottomNavigationView import kotlinx.coroutines.flow.collectLatest @@ -88,7 +88,7 @@ fun HistoryScreen( HistoryDeleteAllDialog( onDismissRequest = onDismissRequest, onDelete = { - presenter.deleteAllHistory() + presenter.removeAllHistory() }, ) } diff --git a/app/src/main/java/eu/kanade/presentation/history/components/HistoryToolbar.kt b/app/src/main/java/eu/kanade/presentation/history/components/HistoryToolbar.kt index 09fab903b..19aef8214 100644 --- a/app/src/main/java/eu/kanade/presentation/history/components/HistoryToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/history/components/HistoryToolbar.kt @@ -10,8 +10,8 @@ import androidx.compose.ui.res.stringResource import eu.kanade.presentation.components.AppBarTitle import eu.kanade.presentation.components.SearchToolbar import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.recent.history.HistoryPresenter -import eu.kanade.tachiyomi.ui.recent.history.HistoryState +import eu.kanade.tachiyomi.ui.history.HistoryPresenter +import eu.kanade.tachiyomi.ui.history.HistoryState @Composable fun HistoryToolbar( diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt index a2a3ca1bb..7a8148a26 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt @@ -35,10 +35,10 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.ui.reader.ReaderActivity -import eu.kanade.tachiyomi.ui.recent.updates.UpdatesItem -import eu.kanade.tachiyomi.ui.recent.updates.UpdatesPresenter -import eu.kanade.tachiyomi.ui.recent.updates.UpdatesPresenter.Dialog -import eu.kanade.tachiyomi.ui.recent.updates.UpdatesPresenter.Event +import eu.kanade.tachiyomi.ui.updates.UpdatesItem +import eu.kanade.tachiyomi.ui.updates.UpdatesPresenter +import eu.kanade.tachiyomi.ui.updates.UpdatesPresenter.Dialog +import eu.kanade.tachiyomi.ui.updates.UpdatesPresenter.Event import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.widget.TachiyomiBottomNavigationView import kotlinx.coroutines.delay diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesState.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesState.kt index 24b3d6486..4e1a9bdd9 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesState.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesState.kt @@ -6,8 +6,8 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import eu.kanade.core.util.insertSeparators -import eu.kanade.tachiyomi.ui.recent.updates.UpdatesItem -import eu.kanade.tachiyomi.ui.recent.updates.UpdatesPresenter +import eu.kanade.tachiyomi.ui.updates.UpdatesItem +import eu.kanade.tachiyomi.ui.updates.UpdatesPresenter import eu.kanade.tachiyomi.util.lang.toDateKey import java.util.Date diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt index c4a2d666f..baaaaefd6 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt @@ -44,7 +44,7 @@ import eu.kanade.presentation.util.horizontalPadding import eu.kanade.presentation.util.selectedBackground import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.download.model.Download -import eu.kanade.tachiyomi.ui.recent.updates.UpdatesItem +import eu.kanade.tachiyomi.ui.updates.UpdatesItem import java.text.DateFormat import java.util.Date import kotlin.time.Duration.Companion.minutes diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/history/HistoryController.kt similarity index 95% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/history/HistoryController.kt index a46cbf624..a7dbf63bb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/history/HistoryController.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent.history +package eu.kanade.tachiyomi.ui.history import androidx.compose.runtime.Composable import eu.kanade.presentation.history.HistoryScreen diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/history/HistoryPresenter.kt similarity index 79% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/history/HistoryPresenter.kt index caa021dae..e252b0026 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/history/HistoryPresenter.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent.history +package eu.kanade.tachiyomi.ui.history import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable @@ -9,11 +9,9 @@ import androidx.compose.runtime.setValue import eu.kanade.core.util.insertSeparators import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.chapter.model.Chapter -import eu.kanade.domain.history.interactor.DeleteAllHistory import eu.kanade.domain.history.interactor.GetHistory -import eu.kanade.domain.history.interactor.GetNextUnreadChapters -import eu.kanade.domain.history.interactor.RemoveHistoryById -import eu.kanade.domain.history.interactor.RemoveHistoryByMangaId +import eu.kanade.domain.history.interactor.GetNextChapters +import eu.kanade.domain.history.interactor.RemoveHistory import eu.kanade.domain.history.model.HistoryWithRelations import eu.kanade.presentation.history.HistoryUiModel import eu.kanade.tachiyomi.R @@ -37,10 +35,8 @@ import java.util.Date class HistoryPresenter( private val state: HistoryStateImpl = HistoryState() as HistoryStateImpl, private val getHistory: GetHistory = Injekt.get(), - private val getNextUnreadChapters: GetNextUnreadChapters = Injekt.get(), - private val deleteAllHistory: DeleteAllHistory = Injekt.get(), - private val removeHistoryById: RemoveHistoryById = Injekt.get(), - private val removeHistoryByMangaId: RemoveHistoryByMangaId = Injekt.get(), + private val getNextChapters: GetNextChapters = Injekt.get(), + private val removeHistory: RemoveHistory = Injekt.get(), preferences: BasePreferences = Injekt.get(), ) : BasePresenter(), HistoryState by state { @@ -48,7 +44,6 @@ class HistoryPresenter( val events: Flow = _events.receiveAsFlow() val isDownloadOnly: Boolean by preferences.downloadedOnly().asState() - val isIncognitoMode: Boolean by preferences.incognitoMode().asState() @Composable @@ -80,39 +75,42 @@ class HistoryPresenter( } } - fun removeFromHistory(history: HistoryWithRelations) { - presenterScope.launchIO { - removeHistoryById.await(history) - } - } - - fun removeAllFromHistory(mangaId: Long) { - presenterScope.launchIO { - removeHistoryByMangaId.await(mangaId) - } - } - fun getNextChapterForManga(mangaId: Long, chapterId: Long) { presenterScope.launchIO { - val chapter = getNextUnreadChapters.await(mangaId, chapterId).firstOrNull() - _events.send(if (chapter != null) Event.OpenChapter(chapter) else Event.NoNextChapterFound) - } - } - - fun deleteAllHistory() { - presenterScope.launchIO { - val result = deleteAllHistory.await() - if (!result) return@launchIO - withUIContext { - view?.activity?.toast(R.string.clear_history_completed) - } + sendNextChapterEvent(getNextChapters.await(mangaId, chapterId, onlyUnread = false)) } } fun resumeLastChapterRead() { presenterScope.launchIO { - val chapter = getNextUnreadChapters.await() - _events.send(if (chapter != null) Event.OpenChapter(chapter) else Event.NoNextChapterFound) + sendNextChapterEvent(getNextChapters.await(onlyUnread = false)) + } + } + + private suspend fun sendNextChapterEvent(chapters: List) { + val chapter = chapters.firstOrNull() + _events.send(if (chapter != null) Event.OpenChapter(chapter) else Event.NoNextChapterFound) + } + + fun removeFromHistory(history: HistoryWithRelations) { + presenterScope.launchIO { + removeHistory.await(history) + } + } + + fun removeAllFromHistory(mangaId: Long) { + presenterScope.launchIO { + removeHistory.await(mangaId) + } + } + + fun removeAllHistory() { + presenterScope.launchIO { + val result = removeHistory.awaitAll() + if (!result) return@launchIO + withUIContext { + view?.activity?.toast(R.string.clear_history_completed) + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index c48b4d838..302249360 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -19,7 +19,7 @@ import eu.kanade.domain.category.interactor.SetMangaCategories import eu.kanade.domain.category.model.Category import eu.kanade.domain.chapter.interactor.SetReadStatus import eu.kanade.domain.chapter.model.toDbChapter -import eu.kanade.domain.history.interactor.GetNextUnreadChapters +import eu.kanade.domain.history.interactor.GetNextChapters import eu.kanade.domain.library.model.LibraryManga import eu.kanade.domain.library.model.LibrarySort import eu.kanade.domain.library.model.sort @@ -78,7 +78,7 @@ class LibraryPresenter( private val getLibraryManga: GetLibraryManga = Injekt.get(), private val getTracksPerManga: GetTracksPerManga = Injekt.get(), private val getCategories: GetCategories = Injekt.get(), - private val getNextUnreadChapters: GetNextUnreadChapters = Injekt.get(), + private val getNextChapters: GetNextChapters = Injekt.get(), private val setReadStatus: SetReadStatus = Injekt.get(), private val updateManga: UpdateManga = Injekt.get(), private val setMangaCategories: SetMangaCategories = Injekt.get(), @@ -410,7 +410,7 @@ class LibraryPresenter( fun downloadUnreadChapters(mangas: List, amount: Int?) { presenterScope.launchNonCancellable { mangas.forEach { manga -> - val chapters = getNextUnreadChapters.await(manga.id) + val chapters = getNextChapters.await(manga.id) .filterNot { chapter -> downloadManager.queue.any { chapter.id == it.chapter.id } || downloadManager.isChapterDownloaded( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 366d9a64a..9770df95f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -52,13 +52,13 @@ import eu.kanade.tachiyomi.ui.browse.BrowseController import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController import eu.kanade.tachiyomi.ui.download.DownloadController +import eu.kanade.tachiyomi.ui.history.HistoryController import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.more.MoreController import eu.kanade.tachiyomi.ui.more.NewUpdateDialogController -import eu.kanade.tachiyomi.ui.recent.history.HistoryController -import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController import eu.kanade.tachiyomi.ui.setting.SettingsMainController +import eu.kanade.tachiyomi.ui.updates.UpdatesController import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchUI import eu.kanade.tachiyomi.util.preference.asHotFlow diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index c3e7b2aba..6590a9012 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -40,6 +40,7 @@ import eu.kanade.tachiyomi.ui.browse.migration.search.SearchController import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceController import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchController import eu.kanade.tachiyomi.ui.category.CategoryController +import eu.kanade.tachiyomi.ui.history.HistoryController import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.manga.MangaPresenter.Dialog @@ -49,8 +50,7 @@ import eu.kanade.tachiyomi.ui.manga.track.TrackItem import eu.kanade.tachiyomi.ui.manga.track.TrackSearchDialog import eu.kanade.tachiyomi.ui.manga.track.TrackSheet import eu.kanade.tachiyomi.ui.reader.ReaderActivity -import eu.kanade.tachiyomi.ui.recent.history.HistoryController -import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController +import eu.kanade.tachiyomi.ui.updates.UpdatesController import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.system.isTabletUi import eu.kanade.tachiyomi.util.system.logcat diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index b33199ef3..74504b4b6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -11,7 +11,7 @@ import eu.kanade.domain.chapter.interactor.UpdateChapter import eu.kanade.domain.chapter.model.ChapterUpdate import eu.kanade.domain.chapter.model.toDbChapter import eu.kanade.domain.download.service.DownloadPreferences -import eu.kanade.domain.history.interactor.GetNextUnreadChapters +import eu.kanade.domain.history.interactor.GetNextChapters import eu.kanade.domain.history.interactor.UpsertHistory import eu.kanade.domain.history.model.HistoryUpdate import eu.kanade.domain.manga.interactor.GetManga @@ -88,7 +88,7 @@ class ReaderPresenter( private val delayedTrackingStore: DelayedTrackingStore = Injekt.get(), private val getManga: GetManga = Injekt.get(), private val getChapterByMangaId: GetChapterByMangaId = Injekt.get(), - private val getNextUnreadChapters: GetNextUnreadChapters = Injekt.get(), + private val getNextChapters: GetNextChapters = Injekt.get(), private val getTracks: GetTracks = Injekt.get(), private val insertTrack: InsertTrack = Injekt.get(), private val upsertHistory: UpsertHistory = Injekt.get(), @@ -475,7 +475,7 @@ class ReaderPresenter( ) if (!isNextChapterDownloaded) return@launchIO - val chaptersToDownload = getNextUnreadChapters.await(manga.id!!, nextChapter.id!!) + val chaptersToDownload = getNextChapters.await(manga.id!!, nextChapter.id!!) .take(amount) downloadManager.downloadChapters( manga.toDomainManga()!!, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesController.kt similarity index 96% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesController.kt index 24784d280..780351b0d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesController.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent.updates +package eu.kanade.tachiyomi.ui.updates import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -26,6 +26,7 @@ class UpdatesController : (activity as? MainActivity)?.moveToStartScreen() }, ) + LaunchedEffect(presenter.selectionMode) { (activity as? MainActivity)?.showBottomNav(presenter.selectionMode.not()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesPresenter.kt similarity index 99% rename from app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt rename to app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesPresenter.kt index 7ba2c0897..48983e84c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/updates/UpdatesPresenter.kt @@ -1,4 +1,4 @@ -package eu.kanade.tachiyomi.ui.recent.updates +package eu.kanade.tachiyomi.ui.updates import android.os.Bundle import androidx.compose.runtime.Immutable @@ -47,13 +47,13 @@ import java.util.Date class UpdatesPresenter( private val state: UpdatesStateImpl = UpdatesState() as UpdatesStateImpl, + private val sourceManager: SourceManager = Injekt.get(), + private val downloadManager: DownloadManager = Injekt.get(), + private val downloadCache: DownloadCache = Injekt.get(), private val updateChapter: UpdateChapter = Injekt.get(), private val setReadStatus: SetReadStatus = Injekt.get(), private val getUpdates: GetUpdates = Injekt.get(), private val getManga: GetManga = Injekt.get(), - private val sourceManager: SourceManager = Injekt.get(), - private val downloadManager: DownloadManager = Injekt.get(), - private val downloadCache: DownloadCache = Injekt.get(), private val getChapter: GetChapter = Injekt.get(), basePreferences: BasePreferences = Injekt.get(), uiPreferences: UiPreferences = Injekt.get(),