Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #1696: Make "My First Ad" use a shorter dismissal duration (#1703)
Browse files Browse the repository at this point in the history
Also ignores the debug override
  • Loading branch information
kylehickinson authored Oct 16, 2019
1 parent 0a173c3 commit 6d86c03
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions BraveRewardsUI/Ads/AdsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ public class AdsViewController: UIViewController {
let animatedOut: () -> Void
}

/// Whether or not this ads container is being used to display "my first ad"
///
/// Setting this to true disables the debug ads override and uses a shorter dismissal duration
private var isFirstAd = false

/// The number of seconds until the "my first ad" is automatically dismissed
private let myFirstAdDismissalInterval: TimeInterval = 3

/// The number of seconds until the ad is automatically dismissed
private let automaticDismissalInterval: TimeInterval = 8

Expand Down Expand Up @@ -93,8 +101,8 @@ public class AdsViewController: UIViewController {
// Invalidate and reschedule
timer.invalidate()
}
var dismissInterval = automaticDismissalInterval
if !AppConstants.BuildChannel.isRelease, let override = Preferences.Rewards.adsDurationOverride.value, override > 0 {
var dismissInterval = isFirstAd ? myFirstAdDismissalInterval : automaticDismissalInterval
if !AppConstants.BuildChannel.isRelease && !isFirstAd, let override = Preferences.Rewards.adsDurationOverride.value, override > 0 {
dismissInterval = TimeInterval(override)
}
dismissTimers[adView] = Timer.scheduledTimer(withTimeInterval: dismissInterval, repeats: false, block: { [weak self] _ in
Expand Down Expand Up @@ -298,6 +306,7 @@ extension AdsViewController {
/// Display a "My First Ad" on a presenting controller and be notified if they tap it
public static func displayFirstAd(on presentingController: UIViewController, completion: @escaping (AdsNotificationHandler.Action, URL) -> Void) {
let adsViewController = AdsViewController()
adsViewController.isFirstAd = true

presentingController.addChild(adsViewController)
presentingController.view.addSubview(adsViewController.view)
Expand Down

0 comments on commit 6d86c03

Please sign in to comment.