Skip to content

Commit 5573125

Browse files
Reset history when navigation state is null and user is making a new search or going to a new URL (#1284)
1 parent 9ffdf3c commit 5573125

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3248,6 +3248,21 @@ class BrowserTabViewModelTest {
32483248
assertCommandIssued<Navigate>()
32493249
}
32503250

3251+
@Test
3252+
fun whenSubmittedQueryAndNavigationStateIsNullThenResetHistoryCommandSent() {
3253+
whenever(mockOmnibarConverter.convertQueryToUrl("nytimes.com", null)).thenReturn("nytimes.com")
3254+
testee.onUserSubmittedQuery("nytimes.com")
3255+
assertCommandIssued<Command.ResetHistory>()
3256+
}
3257+
3258+
@Test
3259+
fun whenSubmittedQueryAndNavigationStateIsNotNullThenResetHistoryCommandNotSent() {
3260+
setupNavigation(isBrowsing = true)
3261+
whenever(mockOmnibarConverter.convertQueryToUrl("nytimes.com", null)).thenReturn("nytimes.com")
3262+
testee.onUserSubmittedQuery("nytimes.com")
3263+
assertCommandNotIssued<Command.ResetHistory>()
3264+
}
3265+
32513266
private suspend fun givenFireButtonPulsing() {
32523267
whenever(mockUserStageStore.getUserAppStage()).thenReturn(AppStage.DAX_ONBOARDING)
32533268
dismissedCtaDaoChannel.send(listOf(DismissedCta(CtaId.DAX_DIALOG_TRACKERS_FOUND)))

app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ class BrowserTabViewModel(
619619
}
620620

621621
private fun shouldClearHistoryOnNewQuery(): Boolean {
622-
val navigation = webNavigationState ?: return false
622+
val navigation = webNavigationState ?: return true
623623
return !currentBrowserViewState().browserShowing && navigation.hasNavigationHistory
624624
}
625625

0 commit comments

Comments
 (0)