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

Commit

Permalink
[ads] Unify iOS kBraveNTPBrandedWallpaper
Browse files Browse the repository at this point in the history
  • Loading branch information
tmancey committed Jan 25, 2024
1 parent 6a8cc08 commit 2b9b57e
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions Sources/Brave/Frontend/Browser/HomePanel/NTPDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ public class NTPDataSource {
/// This is reset on each launch, so `3` can be shown again if app is removed from memory.
/// This number _must_ be less than the number of backgrounds!
private static let numberOfDuplicateAvoidance = 6
/// The number of images in a sponsorship rotation.
/// i.e. This number will be repeated before a new sponsorship is shown.
/// If sposnored image is shown as Nth image, this number of normal images will be shown before Nth is reached again.
private static let sponsorshipShowRate = 4
/// On this value, a sponsored image will be shown.
private static let sponsorshipShowValue = 2

/// The counter that indicates what background should be shown, this is used to determine when a new
/// sponsored image should be shown. (`1` means, first image in cycle N, should be shown).
Expand Down Expand Up @@ -133,7 +127,7 @@ public class NTPDataSource {
if let sponsor = service.sponsoredImageData {
let attemptSponsored =
Preferences.NewTabPage.backgroundSponsoredImages.value
&& backgroundRotationCounter == NTPDataSource.sponsorshipShowValue
&& backgroundRotationCounter == service.initialCountToBrandedWallpaper

Check failure on line 130 in Sources/Brave/Frontend/Browser/HomePanel/NTPDataSource.swift

View workflow job for this annotation

GitHub Actions / Run tests

value of type 'NTPBackgroundImagesService' has no member 'initialCountToBrandedWallpaper'

Check failure on line 130 in Sources/Brave/Frontend/Browser/HomePanel/NTPDataSource.swift

View workflow job for this annotation

GitHub Actions / Run tests

value of type 'NTPBackgroundImagesService' has no member 'initialCountToBrandedWallpaper'

Check failure on line 130 in Sources/Brave/Frontend/Browser/HomePanel/NTPDataSource.swift

View workflow job for this annotation

GitHub Actions / Run tests

value of type 'NTPBackgroundImagesService' has no member 'initialCountToBrandedWallpaper'

Check failure on line 130 in Sources/Brave/Frontend/Browser/HomePanel/NTPDataSource.swift

View workflow job for this annotation

GitHub Actions / Run tests

value of type 'NTPBackgroundImagesService' has no member 'initialCountToBrandedWallpaper'
&& !privateBrowsingManager.isPrivateBrowsing

if attemptSponsored {
Expand Down Expand Up @@ -186,7 +180,7 @@ public class NTPDataSource {
}()

// Force back to `0` if at end
backgroundRotationCounter %= NTPDataSource.sponsorshipShowRate
backgroundRotationCounter %= service.countToBrandedWallpaper

Check failure on line 183 in Sources/Brave/Frontend/Browser/HomePanel/NTPDataSource.swift

View workflow job for this annotation

GitHub Actions / Run tests

value of type 'NTPBackgroundImagesService' has no member 'countToBrandedWallpaper'

Check failure on line 183 in Sources/Brave/Frontend/Browser/HomePanel/NTPDataSource.swift

View workflow job for this annotation

GitHub Actions / Run tests

value of type 'NTPBackgroundImagesService' has no member 'countToBrandedWallpaper'
// Increment regardless, this is a counter, not an index, so smallest should be `1`
backgroundRotationCounter += 1

Expand Down

0 comments on commit 2b9b57e

Please sign in to comment.