-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sam/persistent-pixels
# By Daniel Bernal (12) and others # Via Daniel Bernal (5) and others * main: (46 commits) Release 7.139.0-4 (#3411) Onboarding highlights experiment updates (#3406) fix suggestions performance (#3405) For third party requests differentiate if they are affiliated with first party (#3386) Bump BSK to pull in C-S-S 6.19.0 (#3396) Release 7.139.0-3 (#3399) Onboarding Highlights Ship Review (#3380) add assertions for tabs in suggestions (#3394) Release 7.139.0-2 (#3398) Bump BSK to Include C.S.S 6.17 (#3397) Bump BSK which includes C.S.S 6.17 (#3395) Rever BSK branch Revert "Bump C.S.S" Bump C.S.S translations for Switch to Tab (#3391) Remove Favorites section header from NTP (#3381) Release 7.139.0-1 (#3389) Add origin to /apps URL (#3378) chery pick returning user fix Release 7.138.1-0 (#3388) ... # Conflicts: # DuckDuckGo/AppDependencyProvider.swift
- Loading branch information
Showing
184 changed files
with
6,941 additions
and
1,846 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
MARKETING_VERSION = 7.137.0 | ||
MARKETING_VERSION = 7.139.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// Debouncer.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 DuckDuckGo. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
import Foundation | ||
|
||
/// A class that provides a debouncing mechanism. | ||
public final class Debouncer { | ||
private let runLoop: RunLoop | ||
private let mode: RunLoop.Mode | ||
private var timer: Timer? | ||
|
||
/// Initializes a new instance of `Debouncer`. | ||
/// | ||
/// - Parameters: | ||
/// - runLoop: The `RunLoop` on which the debounced actions will be scheduled. Defaults to the current run loop. | ||
/// | ||
/// - mode: The `RunLoop.Mode` in which the debounced actions will be scheduled. Defaults to `.default`. | ||
/// | ||
/// Use `RunLoop.main` for UI-related actions to ensure they run on the main thread. | ||
public init(runLoop: RunLoop = .current, mode: RunLoop.Mode = .default) { | ||
self.runLoop = runLoop | ||
self.mode = mode | ||
} | ||
|
||
/// Debounces the provided block of code, executing it after a specified time interval elapses. | ||
/// - Parameters: | ||
/// - dueTime: The time interval (in seconds) to wait before executing the block. | ||
/// - block: The closure to execute after the due time has passed. | ||
/// | ||
/// If `dueTime` is less than or equal to zero, the block is executed immediately. | ||
public func debounce(for dueTime: TimeInterval, block: @escaping () -> Void) { | ||
timer?.invalidate() | ||
|
||
guard dueTime > 0 else { return block() } | ||
|
||
let timer = Timer(timeInterval: dueTime, repeats: false, block: { timer in | ||
guard timer.isValid else { return } | ||
block() | ||
}) | ||
|
||
runLoop.add(timer, forMode: mode) | ||
self.timer = timer | ||
} | ||
|
||
/// Cancels any pending execution of the debounced block. | ||
public func cancel() { | ||
timer?.invalidate() | ||
timer = nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.