Skip to content

Commit

Permalink
Fix favorites displayed underneath Dax dialog (#4778)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/488551667048375/1207845944313951/f

### Description
Fix for not showing favorites displayed underneath the 'visit site' Dax
dialog

### Steps to test this PR
On each step, wait for searches and sites to fully load in the browser

- [x] Fresh install
- [x] Perform a search
- [x] Save bookmark → Add favorite
- [x] Visit a site → ⚠️ Don't dismiss the trackers onboarding CTA
- [x] Save bookmark → Add favorite
- [x] Open a new tab
- [x] Perform a search
- [x] Open a new tab
- [x] Check favorites are not displayed underneath Dax dialog
- [x] Tap on a site suggestion
- [x] Check favorites are not displayed underneath Dax dialog before
site is loaded

### UI changes
| Before  | After |
| ------ | ----- |

![Screenshot_20240718_140440](https://github.com/user-attachments/assets/e812d811-9f02-4a87-8ae6-80948f2ff2ab)|![Screenshot
2024-07-19 at 12 37
48](https://github.com/user-attachments/assets/4f683010-0599-4380-b0ce-e420a7097d53)|
  • Loading branch information
nalcalag authored Jul 19, 2024
1 parent 2572ea7 commit f777c5c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ import com.duckduckgo.app.browser.viewstate.LoadingViewState
import com.duckduckgo.app.browser.webview.SslWarningLayout.Action
import com.duckduckgo.app.cta.db.DismissedCtaDao
import com.duckduckgo.app.cta.model.CtaId
import com.duckduckgo.app.cta.model.CtaId.DAX_DIALOG_NETWORK
import com.duckduckgo.app.cta.model.CtaId.DAX_DIALOG_TRACKERS_FOUND
import com.duckduckgo.app.cta.model.CtaId.DAX_END
import com.duckduckgo.app.cta.model.DismissedCta
import com.duckduckgo.app.cta.ui.Cta
Expand Down Expand Up @@ -2366,6 +2368,7 @@ class BrowserTabViewModelTest {
whenever(mockWidgetCapabilities.supportsAutomaticWidgetAdd).thenReturn(false)
whenever(mockWidgetCapabilities.hasInstalledWidgets).thenReturn(true)
whenever(mockDismissedCtaDao.exists(DAX_END)).thenReturn(true)
whenever(mockDismissedCtaDao.exists(DAX_DIALOG_TRACKERS_FOUND)).thenReturn(true)
testee.refreshCta()
assertNull(testee.ctaViewState.value!!.cta)
assertTrue(testee.ctaViewState.value!!.daxOnboardingComplete)
Expand All @@ -2378,6 +2381,7 @@ class BrowserTabViewModelTest {
whenever(mockWidgetCapabilities.supportsAutomaticWidgetAdd).thenReturn(false)
whenever(mockWidgetCapabilities.hasInstalledWidgets).thenReturn(true)
whenever(mockDismissedCtaDao.exists(DAX_END)).thenReturn(true)
whenever(mockDismissedCtaDao.exists(DAX_DIALOG_NETWORK)).thenReturn(true)
testee.refreshCta()
assertNull(testee.ctaViewState.value!!.cta)
assertTrue(testee.ctaViewState.value!!.daxOnboardingComplete)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteEntity
import com.duckduckgo.app.fire.fireproofwebsite.data.FireproofWebsiteRepository
import com.duckduckgo.app.fire.fireproofwebsite.ui.AutomaticFireproofSetting.ALWAYS
import com.duckduckgo.app.fire.fireproofwebsite.ui.AutomaticFireproofSetting.ASK_EVERY_TIME
import com.duckduckgo.app.global.*
import com.duckduckgo.app.global.events.db.UserEventKey
import com.duckduckgo.app.global.events.db.UserEventsStore
import com.duckduckgo.app.global.model.PrivacyShield
Expand Down Expand Up @@ -2442,7 +2441,7 @@ class BrowserTabViewModel @Inject constructor(
)
}
val isOnboardingComplete = withContext(dispatchers.io()) {
ctaViewModel.daxDialogEndShown()
ctaViewModel.areBubbleDaxDialogsCompleted()
}
if (isBrowserShowing && cta != null) hasCtaBeenShownForCurrentPage.set(true)
ctaViewState.value = currentCtaViewState().copy(
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ class CtaViewModel @Inject constructor(

// We only want to show New Tab when the Home CTAs from Onboarding has finished
// https://app.asana.com/0/1157893581871903/1207769731595075/f
fun daxDialogEndShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_END)
fun areBubbleDaxDialogsCompleted(): Boolean {
val bubbleCtasShown = daxDialogEndShown() && (daxDialogNetworkShown() || daxDialogOtherShown() || daxDialogTrackersFoundShown())
return bubbleCtasShown || hideTips()
}

private fun daxDialogSerpShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_DIALOG_SERP)

Expand All @@ -300,6 +303,8 @@ class CtaViewModel @Inject constructor(

private fun daxDialogFireEducationShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_FIRE_BUTTON)

private fun daxDialogEndShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_END)

private fun pulseFireButtonShown(): Boolean = dismissedCtaDao.exists(CtaId.DAX_FIRE_BUTTON_PULSE)

private fun isSerpUrl(url: String): Boolean = url.contains(OnboardingDaxDialogCta.SERP)
Expand Down

0 comments on commit f777c5c

Please sign in to comment.