Fix updating history in incognito mode #783

This commit is contained in:
Koitharu
2024-02-24 13:13:35 +02:00
parent e97a745713
commit 45c3c05f01
6 changed files with 10 additions and 3 deletions

View File

@@ -57,6 +57,7 @@ class AppShortcutManagerTest {
page = 4,
scroll = 2,
percent = 0.3f,
force = false,
)
awaitUpdate()

View File

@@ -7,7 +7,9 @@ import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest
import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -61,6 +63,7 @@ class AppBackupAgentTest {
page = 3,
scroll = 40,
percent = 0.2f,
force = false,
)
val history = checkNotNull(historyRepository.getOne(SampleData.manga))

View File

@@ -320,6 +320,7 @@ class DetailsViewModel @Inject constructor(
page = 0,
scroll = 0,
percent = percent,
force = true,
)
}
}

View File

@@ -90,8 +90,8 @@ class HistoryRepository @Inject constructor(
.distinctUntilChanged()
}
suspend fun addOrUpdate(manga: Manga, chapterId: Long, page: Int, scroll: Int, percent: Float) {
if (shouldSkip(manga)) {
suspend fun addOrUpdate(manga: Manga, chapterId: Long, page: Int, scroll: Int, percent: Float, force: Boolean) {
if (!force && shouldSkip(manga)) {
return
}
db.withTransaction {

View File

@@ -24,6 +24,7 @@ class HistoryUpdateUseCase @Inject constructor(
page = readerState.page,
scroll = readerState.scroll,
percent = percent,
force = false,
)
}

View File

@@ -30,6 +30,7 @@ class MarkAsReadUseCase @Inject constructor(
page = pages.lastIndex,
scroll = 0,
percent = 1f,
force = true,
)
}