From 4a55da6d370a89ddd6720680a39f99fdbe64d267 Mon Sep 17 00:00:00 2001 From: Christopher Brind Date: Mon, 26 Feb 2024 15:04:14 +0000 Subject: [PATCH] Fixes the firing of `mh` pixel (#2503) Task/Issue URL: https://app.asana.com/0/414709148257752/1206674614649925/f Tech Design URL: CC: Description: Fixes the firing of mh pixel Steps to test this PR: Launch the app, ensure mh pixel is fired when the the new tab is shown Create tabs from the tab switcher. mh should only be fired when the the user ends up on the Home Screen Check RMF message still displays as expected --- DuckDuckGo/HomeViewController.swift | 10 ++++++---- DuckDuckGo/MainViewController.swift | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/DuckDuckGo/HomeViewController.swift b/DuckDuckGo/HomeViewController.swift index 3d79ff3747..e79caf0368 100644 --- a/DuckDuckGo/HomeViewController.swift +++ b/DuckDuckGo/HomeViewController.swift @@ -264,12 +264,14 @@ class HomeViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - - if presentedViewController == nil { // prevents these being called when settings forces this controller to be reattached - showNextDaxDialog() - } + + // If there's no tab switcher then this will be true, if there is a tabswitcher then only allow the + // stuff below to happen if it's being dismissed + guard presentedViewController?.isBeingDismissed ?? true else { return } Pixel.fire(pixel: .homeScreenShown) + showNextDaxDialog() + collectionView.didAppear() viewHasAppeared = true diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index c4b19b187d..0860b07266 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -2058,8 +2058,12 @@ extension MainViewController: TabSwitcherDelegate { func tabSwitcher(_ tabSwitcher: TabSwitcherViewController, didRemoveTab tab: Tab) { if tabManager.count == 1 { // Make sure UI updates finish before dimissing the view. + // However, as a result, viewDidAppear on the home controller thinks the tab + // switcher is still presented. DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { - tabSwitcher.dismiss() + tabSwitcher.dismiss(animated: true) { + self.homeController?.viewDidAppear(true) + } } } closeTab(tab)