-
Notifications
You must be signed in to change notification settings - Fork 26
Make getEvents less restrictive #55
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
Conversation
WalkthroughThis update introduces a new Changes
Sequence Diagram(s)sequenceDiagram
participant JS as React Native JS
participant Swift as iOS Native (Swift)
participant Ext as DeviceActivity/ShieldAction Extension
JS->>Swift: Dispatch ShieldAction (with actions array)
Swift->>Ext: handleShieldAction(config, placeholders, tokens)
loop For each action in config["actions"]
Ext->>Swift: executeGenericAction(action, placeholders, tokens)
Swift-->>Ext: (Performs action: badge, notification, HTTP, etc.)
end
Ext-->>Swift: ShieldActionResponse
Swift-->>JS: Result/Completion
Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/react-native-device-activity/src/ReactNativeDeviceActivity.types.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "universe/native" to extend from. Please check that the name of the config is correct. The config "universe/native" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. ✨ Finishing Touches
🪧 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 (
|
commit: |
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: 7
🔭 Outside diff range comments (1)
packages/react-native-device-activity/targets/ShieldAction/ShieldActionExtension.swift (1)
136-153: 🛠️ Refactor suggestionDuplicate implementation – consolidate with
executeGenericActionThe
"addCurrentToWhitelist"logic is now implemented both here and insideexecuteGenericAction, risking divergence.Prefer calling
executeGenericAction(or deleting this branch) to keep behaviour in one place.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (6)
packages/react-native-device-activity/ios/ReactNativeDeviceActivityModule.swift(1 hunks)packages/react-native-device-activity/ios/Shared.swift(1 hunks)packages/react-native-device-activity/package.json(1 hunks)packages/react-native-device-activity/src/ReactNativeDeviceActivity.types.ts(3 hunks)packages/react-native-device-activity/targets/ActivityMonitorExtension/DeviceActivityMonitorExtension.swift(4 hunks)packages/react-native-device-activity/targets/ShieldAction/ShieldActionExtension.swift(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
packages/react-native-device-activity/targets/ActivityMonitorExtension/DeviceActivityMonitorExtension.swift (1)
packages/react-native-device-activity/ios/Shared.swift (1)
executeGenericAction(100-246)
packages/react-native-device-activity/ios/Shared.swift (1)
packages/react-native-device-activity/src/index.ts (9)
updateShield(569-584)blockSelection(424-436)unblockSelection(450-462)addSelectionToWhitelistAndUpdateBlock(135-147)removeSelectionFromWhitelistAndUpdateBlock(149-161)clearWhitelist(105-107)resetBlocks(446-448)disableBlockAllMode(442-444)enableBlockAllMode(438-440)
packages/react-native-device-activity/targets/ShieldAction/ShieldActionExtension.swift (1)
packages/react-native-device-activity/ios/Shared.swift (1)
executeGenericAction(100-246)
🔇 Additional comments (8)
packages/react-native-device-activity/package.json (1)
3-3: Version bump from 0.4.24 to 0.4.28This version increase corresponds with the significant changes to the action system in this PR, including the introduction of the generic action execution function and new shield action types.
packages/react-native-device-activity/ios/ReactNativeDeviceActivityModule.swift (1)
356-356: Broadening event filtering logicThe filtering criteria has been relaxed to match any keys that start with the activityName, rather than requiring an exact format with a trailing underscore. This aligns with the PR objective to make event filtering less restrictive.
packages/react-native-device-activity/targets/ActivityMonitorExtension/DeviceActivityMonitorExtension.swift (3)
12-12: Added NotificationCenter importAdded import for NotificationCenter which is required for the notification functionality used with the new action system.
57-58: Improved variable namingRenamed variable from
keytotriggeredBywhich better describes its purpose and improves code readability.
103-107: Migrated to centralized action executionReplaced the specialized
executeActionfunction with the new centralizedexecuteGenericActionfunction from Shared.swift. This refactoring improves code maintainability and allows for a more consistent handling of actions across the codebase.packages/react-native-device-activity/src/ReactNativeDeviceActivity.types.ts (3)
163-163: Renamed action type for clarityChanged
"whitelistCurrent"to"addCurrentToWhitelist"for improved clarity and consistency with other action naming conventions.
173-174: Enhanced ShieldAction with multi-action supportDeprecated the single
typeproperty in favor of an array-basedactionsproperty. This provides greater flexibility by allowing multiple sequential actions to be defined within a single ShieldAction.Also applies to: 182-182
272-289: Added new action types for enhanced functionalityExtended the Action union type with several new capabilities:
- Badge count management
- Notification request handling
- Whitelist management
These additions align with the enhanced generic action execution functionality implemented in the iOS native code.
Allow any events starting with the specified activityName
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Chores