-
Notifications
You must be signed in to change notification settings - Fork 424
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
Onboarding Highlights Ship Review #3380
Merged
alessandroboron
merged 21 commits into
release/7.139.0
from
alessandro/onboarding-highlights-ship-review
Sep 26, 2024
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cd50785
Add translations
alessandroboron 706b0f5
Remove progress bar text that should not be translated
alessandroboron 5becc09
SH1/ Fix Onboarding Address bar position button colors
alessandroboron 209dd06
SH2/ Fix search suggestions for US country
alessandroboron 0d20514
Mitgate issue where no tracker dialog is shown instead of blocked tra…
alessandroboron 41ffb26
SH5/ Show baby ducklings images
alessandroboron b71fde3
SH6/ Debounce redirects
alessandroboron fea1811
PH1/ Lowercase "default" string
alessandroboron 9074a20
SH3/ Make DuckDuckGo Search bold
alessandroboron 907a1f3
Remove fixed offset for AppIcon picker
alessandroboron c6d2dcc
Add translations
alessandroboron 220bea6
Fix spacing in App Icons
alessandroboron 5445995
Fix swiftlint issues
alessandroboron add3526
Fix an issue where when the user dismisses a dialog because no subseq…
alessandroboron 94582cb
Fix an issue that caused fire dialog to show it again when clearing b…
alessandroboron 9034e9d
Fix an issue that shows the initial NTP dialog if the user clear brow…
alessandroboron 10daa7a
Fix an issue that cause showing again the Dax dialog for last visited…
alessandroboron ebf9470
Address PR comments
alessandroboron 65ae469
Dismiss DaxDialogs when using swipe to navigate to avoid showing bloc…
alessandroboron 19e2495
Onboarding Highlights - Experiment Setup (#3390)
alessandroboron 5435710
Fix Package.resolved
alessandroboron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems old school to implement this with timers when Combine has one built in but:
1/ Then you'd need to pass in the debounce time in the constructor
2/ It's probably just as many lines of code as this
No change required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m fine to change to use Combine under the hood if we want, but yeah probably the lines of code will be very similar.