Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jaceklyp committed May 9, 2024
1 parent 5fe2443 commit 8d2450b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1234,19 +1234,18 @@ class MainViewController: UIViewController {
])

self.notificationView = contentView
view.layoutSubviews()
viewCoordinator.topSlideContainer.layoutIfNeeded()

view.layoutSubviews()
viewCoordinator.showTopSlideContainer()
UIView.animate(withDuration: 0.4) {
UIView.animate(withDuration: 0.3) {
self.view.layoutIfNeeded()
}
}

func hideNotification() {
self.view.layoutIfNeeded()
view.layoutIfNeeded()
viewCoordinator.hideTopSlideContainer()
UIView.animate(withDuration: 0.4) {
UIView.animate(withDuration: 0.3) {
self.view.layoutIfNeeded()
} completion: { _ in
self.notificationView?.removeFromSuperview()
Expand All @@ -1271,13 +1270,15 @@ class MainViewController: UIViewController {
private var brokenSitePromptEvent: UserBehaviorEvent?

@objc func attemptToShowBrokenSitePrompt(_ notification: Notification) {
guard userDidInteractWithBrokenSitePrompt,
guard /*userDidInteractWithBrokenSitePrompt,*/
let event = notification.userInfo?[UserBehaviorEvent.Key.event] as? UserBehaviorEvent,
let url = currentTab?.url, !url.isDuckDuckGo,
notificationView == nil,
!isPad,
DefaultTutorialSettings().hasSeenOnboarding else { return }
showBrokenSitePrompt(after: event)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.showBrokenSitePrompt(after: event)
}
}

private func showBrokenSitePrompt(after event: UserBehaviorEvent) {
Expand Down Expand Up @@ -1874,9 +1875,9 @@ extension MainViewController: OmniBarDelegate {
func onRefreshPressed() {
hideSuggestionTray()
currentTab?.refresh()
hideNotification()
if brokenSitePromptViewHostingController != nil, let event = brokenSitePromptEvent?.rawValue {
Pixel.fire(pixel: .siteNotWorkingDismissByRefresh,
hideNotification()
Pixel.fire(pixel: .siteNotWorkingDismissByRefresh,
withAdditionalParameters: [UserBehaviorEvent.Parameter.event: event])
}
}
Expand Down
4 changes: 2 additions & 2 deletions DuckDuckGo/UserBehaviorMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ final class UserBehaviorMonitor {
func fireEventIfActionOccurredRecently(within interval: Double = 30.0, since timestamp: Date?, eventToFire: UserBehaviorEvent) {
if let timestamp = timestamp, date.timeIntervalSince(timestamp) < interval {
eventMapping.fire(eventToFire)
if PixelExperimentForBrokenSites.cohort == eventToFire.matchingPixelExperimentVariant {
// if PixelExperimentForBrokenSites.cohort == eventToFire.matchingPixelExperimentVariant {
NotificationCenter.default.post(name: .userBehaviorDidMatchExperimentVariant,
object: self,

Check failure on line 110 in DuckDuckGo/UserBehaviorMonitor.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
userInfo: [UserBehaviorEvent.Key.event: eventToFire])
}
// }
}
}
}
Expand Down

0 comments on commit 8d2450b

Please sign in to comment.