Improved the saving of tabs history.

* Fixed: `testPreviouslyLoadedArticleLoadsAgainWhenSwitchingToAnotherScreen` which sometimes failing on API level 33.
This commit is contained in:
MohitMaliFtechiz 2025-09-03 12:00:47 +05:30
parent 1824390703
commit f8a339624a
2 changed files with 5 additions and 4 deletions

View File

@ -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 {

View File

@ -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()