Fix updating history in incognito mode #783

master
Koitharu 2 years ago
parent e97a745713
commit 45c3c05f01
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

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

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

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

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

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

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

Loading…
Cancel
Save