Skip to content
This repository was archived by the owner on Jun 23, 2020. It is now read-only.

Commit 59156ae

Browse files
Daniel Jilgpavel-cliqz
authored andcommitted
[IB-1891] Save the preference value that the intro has been seen (#378)
* Cliqz: set the blocker settings to recommended settings * Extract Blocker Setup into Static function * Save the preference value that the intro has been seen * Gate setupBlocking function because it wont compile in PAID
1 parent 5be1f99 commit 59156ae

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

Client/Frontend/Browser/BrowserViewController.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,8 +2290,14 @@ extension BrowserViewController: IntroViewControllerDelegate {
22902290
@discardableResult func presentIntroViewController(_ force: Bool = false, animated: Bool = true) -> Bool {
22912291
// Cliqz: Don't show onboarding for Cliqz for now
22922292
#if CLIQZ
2293+
// Setup Default Blocking Settings
2294+
CliqzIntroViewController.setupBlocking(blockOptionSelected: .recommended)
2295+
2296+
// Save the preference value that the intro has been seen
2297+
self.profile.prefs.setInt(1, forKey: PrefsKeys.IntroSeen)
22932298
return false
22942299
#endif
2300+
// End Cliqz
22952301

22962302
//Cliqz: This is temporary. We should remove this once we have an Intro.
22972303
if let deeplink = self.profile.prefs.stringForKey("AdjustDeeplinkKey"), let url = URL(string: deeplink) {
@@ -2303,9 +2309,6 @@ extension BrowserViewController: IntroViewControllerDelegate {
23032309
#if PAID
23042310
let introViewController = LumenIntroViewController()
23052311
#else
2306-
/* Cliqz: Change to CliqzIntroViewController
2307-
let introViewController = IntroViewController()
2308-
*/
23092312
let introViewController = CliqzIntroViewController()
23102313
#endif
23112314

Cliqz/Intro/CliqzIntroViewController.swift

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,32 +246,41 @@ class CliqzIntroViewController: UIViewController {
246246

247247
#if PAID
248248
#else
249-
let populateOp = PopulateBlockedTrackersOperation()
249+
CliqzIntroViewController.setupBlocking(blockOptionSelected: blockOptionSelected)
250+
#endif
250251

252+
delegate?.introViewControllerDidFinish(self, requestToLogin: false)
253+
}
254+
255+
#if PAID
256+
#else
257+
static func setupBlocking(blockOptionSelected: BlockOption) {
258+
let populateOp = PopulateBlockedTrackersOperation()
259+
251260
var loadOp: LoadTrackerListOperation? = nil
252-
261+
253262
let loadOperations = GlobalPrivacyQueue.shared.operations.filter { (op) -> Bool in
254263
return op is LoadTrackerListOperation && !(op.isFinished || op.isCancelled)
255264
}
256-
265+
257266
if !loadOperations.isEmpty, let loadOperation = loadOperations.first as? LoadTrackerListOperation {
258267
loadOp = loadOperation
259268
}
260-
269+
261270
func addOp(operation: Operation) {
262271
if let loadOperation = loadOp {
263272
operation.addDependency(loadOperation)
264273
}
265-
274+
266275
populateOp.addDependency(operation)
267-
276+
268277
GlobalPrivacyQueue.shared.addOperation(operation)
269278
GlobalPrivacyQueue.shared.addOperation(populateOp)
270279
}
271-
280+
272281
if blockOptionSelected != .recommended {
273282
let blockOption: ChangeTrackersOperation.BlockOption = blockOptionSelected == .all ? .blockAll : .unblockAll
274-
283+
275284
let operation = ChangeTrackersOperation(blockOption: blockOption)
276285
addOp(operation: operation)
277286
}
@@ -281,11 +290,8 @@ class CliqzIntroViewController: UIViewController {
281290
UserDefaults.standard.set(true, forKey: trackersDefaultsAreAppliedKey)
282291
UserDefaults.standard.synchronize()
283292
}
284-
285-
#endif
286-
287-
delegate?.introViewControllerDidFinish(self, requestToLogin: false)
288293
}
294+
#endif
289295

290296
func login() {
291297
delegate?.introViewControllerDidFinish(self, requestToLogin: true)

0 commit comments

Comments
 (0)