Skip to content

Commit

Permalink
Fire Button Highlight bug (#5582)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1201807753394693/1209307760721992

### Description
Remove highlight on fire button after Fire dialog is dismissed

### Steps to test this PR

- [ ] Fresh install
- [ ] Go to browser
- [ ] Go to a trackers website (e.g. bbc.co.uk)
- [ ] Tap on Got it! button
- [ ] Check Fire button is highlighted
- [ ] Tap on Skip
- [ ] Check Fire button highlight is removed


### No UI changes
  • Loading branch information
nalcalag authored Feb 3, 2025
1 parent 9625e45 commit 48599da
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2727,6 +2727,9 @@ class BrowserTabViewModel @Inject constructor(
viewModelScope.launch {
ctaViewModel.onUserDismissedCta(it)
}
if (cta is OnboardingDaxDialogCta.DaxTrackersBlockedCta && currentBrowserViewState().showPrivacyShield.isHighlighted()) {
browserViewState.value = currentBrowserViewState().copy(showPrivacyShield = HighlightableButton.Visible(highlighted = false))
}
}
}

Expand Down Expand Up @@ -3539,9 +3542,6 @@ class BrowserTabViewModel @Inject constructor(
is OnboardingDaxDialogCta.DaxNoTrackersCta,
is OnboardingDaxDialogCta.DaxMainNetworkCta,
-> {
if (currentBrowserViewState().showPrivacyShield.isHighlighted()) {
browserViewState.value = currentBrowserViewState().copy(showPrivacyShield = HighlightableButton.Visible(highlighted = false))
}
viewModelScope.launch {
val cta = withContext(dispatchers.io()) { ctaViewModel.getFireDialogCta() }
ctaViewState.value = currentCtaViewState().copy(cta = cta)
Expand Down Expand Up @@ -3579,10 +3579,6 @@ class BrowserTabViewModel @Inject constructor(
}

private fun onDismissOnboardingDaxDialog(cta: OnboardingDaxDialogCta) {
if (cta is OnboardingDaxDialogCta.DaxTrackersBlockedCta) {
browserViewState.value = currentBrowserViewState().copy(showPrivacyShield = HighlightableButton.Visible(highlighted = false))
}

onUserDismissedCta(cta)
command.value = HideOnboardingDaxDialog(cta)
}
Expand All @@ -3593,11 +3589,6 @@ class BrowserTabViewModel @Inject constructor(
onUserDismissedCta(cta)
command.value = HideOnboardingDaxDialog(cta as OnboardingDaxDialogCta)
}
if (currentBrowserViewState().fireButton.isHighlighted()) {
viewModelScope.launch {
ctaViewModel.dismissPulseAnimation()
}
}
}

fun onPrivacyShieldSelected() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,36 +451,18 @@ class OmnibarLayoutViewModel @Inject constructor(
}

fun onHighlightItem(decoration: OmnibarLayout.Decoration.HighlightOmnibarItem) {
if (decoration.privacyShield) {
_viewState.update {
it.copy(
highlightPrivacyShield = HighlightableButton.Visible(
enabled = true,
highlighted = true,
),
highlightFireButton = HighlightableButton.Visible(
enabled = true,
highlighted = false,
),
scrollingEnabled = false,
)
}
}

if (decoration.fireButton) {
_viewState.update {
it.copy(
highlightPrivacyShield = HighlightableButton.Visible(
enabled = true,
highlighted = false,
),
highlightFireButton = HighlightableButton.Visible(
enabled = true,
highlighted = true,
),
scrollingEnabled = false,
)
}
_viewState.update {
it.copy(
highlightPrivacyShield = HighlightableButton.Visible(
enabled = true,
highlighted = decoration.privacyShield,
),
highlightFireButton = HighlightableButton.Visible(
enabled = true,
highlighted = decoration.fireButton,
),
scrollingEnabled = false,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,29 @@ class OmnibarLayoutViewModelTest {
}
}

@Test
fun whenFireButtonItemHighlightedRemovedThenViewStateCorrect() = runTest {
testee.onHighlightItem(Decoration.HighlightOmnibarItem(fireButton = false, privacyShield = false))
testee.viewState.test {
val viewState = awaitItem()
assertTrue(
viewState.highlightPrivacyShield == HighlightableButton.Visible(
enabled = true,
highlighted = false,
),
)

assertTrue(
viewState.highlightFireButton == HighlightableButton.Visible(
enabled = true,
highlighted = false,
),
)

assertFalse(viewState.scrollingEnabled)
}
}

@Test
fun whenFireIconPressedAndFireIconHighlightedThenViewStateCorrectAndPixelSent() = runTest {
val animationPlaying = true
Expand Down

0 comments on commit 48599da

Please sign in to comment.