Skip to content

[ads] NTT should be served only once during the grace period #28970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,16 @@ public class NTPDataSource {
}

func getSponsoredMediaBackground() -> NTPWallpaper? {
guard let sponsoredImageData = service.sponsoredImageData,
let newTabPageAd = rewards?.ads.maybeGetPrefetchedNewTabPageAd()
guard let sponsoredImageData = service.sponsoredImageData
else { return nil }

if !hasGracePeriodEnded(sponsoredImageData) {
return nil
}

guard let newTabPageAd = rewards?.ads.maybeGetPrefetchedNewTabPageAd()
else { return nil }

let isSponsoredVideoAllowed =
Preferences.NewTabPage.backgroundMediaType == .sponsoredImagesAndVideos

Expand Down Expand Up @@ -248,7 +250,16 @@ public class NTPDataSource {
return true
}

return Date.now.timeIntervalSince(installDate) > gracePeriod
let gracePeriodEndAt = installDate + TimeInterval(gracePeriod)
if Date.now >= gracePeriodEndAt {
return true
}

print(
"Sponsored images not shown: Grace period after installation is",
"still active until \(gracePeriodEndAt)"
)
return false
}
}

Expand Down
Loading