feat: use DebounceButton for the crop button in the CropToolbar#425
feat: use DebounceButton for the crop button in the CropToolbar#425guoyingtao wants to merge 2 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new DebounceButton to prevent multiple rapid taps on the crop button and updates the CropToolbar to use it.
- Added DebounceButton.swift implementing debouncing functionality
- Updated CropToolbar.swift to use DebounceButton and assign crop operations via closures
- Updated the project file to reference the new DebounceButton.swift
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Sources/Mantis/CropViewController/DebounceButton.swift | New file implementing debouncing for button taps |
| Sources/Mantis/CropViewController/CropToolbar.swift | Updated crop button type and setup using DebounceButton |
| Mantis.xcodeproj/project.pbxproj | Added project references for DebounceButton |
| isEnabled = false | ||
| cropOperation() | ||
|
|
||
| DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in |
There was a problem hiding this comment.
Consider using debounceInterval instead of the hardcoded 0.5 seconds for re-enabling the button, to ensure consistent debounce behavior when the interval is customized.
| DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in | |
| DispatchQueue.main.asyncAfter(deadline: .now() + self?.debounceInterval ?? 0.5) { [weak self] in |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughA new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DebounceButton
participant CropToolbar
User->>DebounceButton: Tap Crop Button
DebounceButton->>DebounceButton: Check debounce interval & processing state
alt Not processing and interval elapsed
DebounceButton->>DebounceButton: Disable button, set processing
DebounceButton->>CropToolbar: Execute crop operation closure
Note right of DebounceButton: Wait 0.5 seconds
DebounceButton->>DebounceButton: Enable button, reset processing
else Rapid tap or processing
DebounceButton-->>User: Ignore tap
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🔇 Additional comments (7)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Summary by CodeRabbit