mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 05:27:28 +01:00
Minor cleanup
This commit is contained in:
@@ -90,6 +90,7 @@ import eu.kanade.tachiyomi.util.view.setComposeContent
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -243,14 +244,13 @@ class MainActivity : BaseActivity() {
|
||||
LaunchedEffect(Unit) {
|
||||
preferences.incognitoMode().changes()
|
||||
.drop(1)
|
||||
.filter { !it }
|
||||
.onEach {
|
||||
if (!it) {
|
||||
val currentScreen = navigator.lastItem
|
||||
if (currentScreen is BrowseSourceScreen ||
|
||||
(currentScreen is MangaScreen && currentScreen.fromSource)
|
||||
) {
|
||||
navigator.popUntilRoot()
|
||||
}
|
||||
val currentScreen = navigator.lastItem
|
||||
if (currentScreen is BrowseSourceScreen ||
|
||||
(currentScreen is MangaScreen && currentScreen.fromSource)
|
||||
) {
|
||||
navigator.popUntilRoot()
|
||||
}
|
||||
}
|
||||
.launchIn(this)
|
||||
|
||||
@@ -389,10 +389,10 @@ class MangaInfoScreenModel(
|
||||
|
||||
fun moveMangaToCategoriesAndAddToLibrary(manga: Manga, categories: List<Long>) {
|
||||
moveMangaToCategory(categories)
|
||||
if (!manga.favorite) {
|
||||
coroutineScope.launchIO {
|
||||
updateManga.awaitUpdateFavorite(manga.id, true)
|
||||
}
|
||||
if (manga.favorite) return
|
||||
|
||||
coroutineScope.launchIO {
|
||||
updateManga.awaitUpdateFavorite(manga.id, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -532,17 +532,14 @@ class ReaderViewModel(
|
||||
* Saves this [readerChapter] last read history if incognito mode isn't on.
|
||||
*/
|
||||
private suspend fun saveChapterHistory(readerChapter: ReaderChapter) {
|
||||
if (!incognitoMode) {
|
||||
val chapterId = readerChapter.chapter.id!!
|
||||
val readAt = Date()
|
||||
val sessionReadDuration = chapterReadStartTime?.let { readAt.time - it } ?: 0
|
||||
if (incognitoMode) return
|
||||
|
||||
upsertHistory.await(
|
||||
HistoryUpdate(chapterId, readAt, sessionReadDuration),
|
||||
).also {
|
||||
chapterReadStartTime = null
|
||||
}
|
||||
}
|
||||
val chapterId = readerChapter.chapter.id!!
|
||||
val endTime = Date()
|
||||
val sessionReadDuration = chapterReadStartTime?.let { endTime.time - it } ?: 0
|
||||
|
||||
upsertHistory.await(HistoryUpdate(chapterId, endTime, sessionReadDuration))
|
||||
chapterReadStartTime = null
|
||||
}
|
||||
|
||||
fun setReadStartTime() {
|
||||
|
||||
Reference in New Issue
Block a user