diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderFragment.kt index 6bf9fc4d4..c424ca6fc 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderFragment.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderFragment.kt @@ -2232,10 +2232,6 @@ abstract class CoreReaderFragment : private fun saveTabStates(onComplete: () -> Unit = {}) { CoroutineScope(Dispatchers.Main).launch { savingTabsMutex.withLock { - // clear the previous history saved in database - withContext(Dispatchers.IO) { - repositoryActions?.clearWebViewPageHistory() - } val coreApp = sharedPreferenceUtil?.context as CoreApp val settings = coreApp.getSharedPreferences( SharedPreferenceUtil.PREF_KIWIX_MOBILE, @@ -2247,6 +2243,9 @@ abstract class CoreReaderFragment : getWebViewHistoryEntity(view, index)?.let(webViewHistoryEntityList::add) } withContext(Dispatchers.IO) { + // clear the previous history saved in database + repositoryActions?.clearWebViewPageHistory() + // Store new history in database. repositoryActions?.saveWebViewPageHistory(webViewHistoryEntityList) } settings.edit { diff --git a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt index 1f5a75894..cefec90e5 100644 --- a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt +++ b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt @@ -299,7 +299,9 @@ class SearchFragmentTestForCustomApp { clickOnHomeButton(composeTestRule) // click on an article to load the other page. clickOnAFoolForYouArticle(composeTestRule) + composeTestRule.mainClock.advanceTimeByFrame() assertAFoolForYouArticleLoaded(composeTestRule) + composeTestRule.waitUntilTimeout() // open note screen. openNoteFragment(customMainActivity as CoreMainActivity, composeTestRule) composeTestRule.waitUntilTimeout()