-
Notifications
You must be signed in to change notification settings - Fork 0
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
Swift 6 Fixes #104
Swift 6 Fixes #104
Conversation
WalkthroughThe changes involve the addition of the Changes
Sequence Diagram(s)sequenceDiagram
participant MainActor
participant QRScannerViewDelegate
MainActor->>QRScannerViewDelegate: Call method
QRScannerViewDelegate->>MainActor: Execute on main thread
MainActor->>QRScannerViewDelegate: Return result
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
Quality Gate passedIssues Measures |
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
Sources/UBPush/UBPushManager.swift (3)
175-178
: Ensure UI updates occur on the main actorWrapping the registration code within
Task { @MainActor in ... }
ensures that UI-related operations are executed on the main actor, which is necessary for thread safety when interacting with UI elements.Note: Line 178 exceeds the maximum line length of 120 characters as indicated by SwiftLint.
Consider refactoring to comply with the line length guideline:
Task { @MainActor in - UNUserNotificationCenter.current().setNotificationCategories(self.pushHandler.notificationCategories) + UNUserNotificationCenter.current() + .setNotificationCategories(self.pushHandler.notificationCategories) UIApplication.shared.registerForRemoteNotifications() }🧰 Tools
🪛 SwiftLint
[Warning] 178-178: Line should be 120 characters or less; currently it has 121 characters
(line_length)
Line range hint
285-293
: SimplifyopenSettingsFor
method by eliminating redundant conditionalsThe
userNotificationCenter(_:openSettingsFor:)
method can be simplified by directly passing the optionalnotification
topushHandler.openInAppSettings(_:)
, eliminating the need for the conditional check.Consider refactoring the method:
public nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) { - if let notification { - Task { @MainActor in - pushHandler.openInAppSettings(notification) - } - } else { - Task { @MainActor in - pushHandler.openInAppSettings(nil) - } - } + Task { @MainActor in + pushHandler.openInAppSettings(notification) + } }
Line range hint
304-310
: Correct thefailure
computed property inPermissionRequestResult
extensionThe
failure
computed property uses anif
statement without an accompanying return statement inside the block, which will lead to a compilation error.Apply this diff to fix the logic:
static var failure: UBPushManager.PermissionRequestResult { - if - let settingsUrl = UIApplication.ub_appNotificationSettingsURL, - UIApplication.shared.canOpenURL(settingsUrl) { - .recoverableFailure(settingsURL: settingsUrl) - } else { - .nonRecoverableFailure - } + if let settingsUrl = UIApplication.ub_appNotificationSettingsURL, + UIApplication.shared.canOpenURL(settingsUrl) { + return .recoverableFailure(settingsURL: settingsUrl) + } else { + return .nonRecoverableFailure + } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- Sources/UBPush/UBPushManager.swift (4 hunks)
🧰 Additional context used
🪛 SwiftLint
Sources/UBPush/UBPushManager.swift
[Warning] 178-178: Line should be 120 characters or less; currently it has 121 characters
(line_length)
🔇 Additional comments (4)
Sources/UBPush/UBPushManager.swift (4)
55-55
: Good use of@Sendable
for concurrency safetyAdding
@Sendable
to thePermissionRequestCallback
closure ensures that it can be safely passed across concurrency domains, enhancing thread safety and aligning with Swift's concurrency model.
204-204
: Appropriate use of@Sendable
in authorization closureAdding
@Sendable
to the closure inrequestAuthorization
ensures that the closure can be safely executed in a concurrent environment, promoting thread safety.
225-226
: Maintain main actor execution for notification registrationUsing
Task { @MainActor in ... }
ensures that the setting of notification categories and the registration for remote notifications occur on the main actor, which is crucial for updating UI-related components.
Line range hint
270-273
: Consistent use ofTask { @MainActor in ... }
in delegate methodsWrapping push handler calls within
Task { @MainActor in ... }
in theUNUserNotificationCenterDelegate
methods ensures that UI updates are performed on the main actor, maintaining thread safety.
|
||
DispatchQueue.main.async { | ||
Task { @MainActor in | ||
UNUserNotificationCenter.current().setNotificationCategories(self.pushHandler.notificationCategories) |
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.
Line exceeds maximum allowed length
Line 178 exceeds the maximum line length of 120 characters as indicated by SwiftLint. This could impact code readability.
Consider breaking the line to improve readability:
Task { @MainActor in
- UNUserNotificationCenter.current().setNotificationCategories(self.pushHandler.notificationCategories)
+ UNUserNotificationCenter.current()
+ .setNotificationCategories(self.pushHandler.notificationCategories)
UIApplication.shared.registerForRemoteNotifications()
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
UNUserNotificationCenter.current().setNotificationCategories(self.pushHandler.notificationCategories) | |
UNUserNotificationCenter.current() | |
.setNotificationCategories(self.pushHandler.notificationCategories) |
🧰 Tools
🪛 SwiftLint
[Warning] 178-178: Line should be 120 characters or less; currently it has 121 characters
(line_length)
Summary by CodeRabbit