-
Notifications
You must be signed in to change notification settings - Fork 26
Improve docs #57
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
Improve docs #57
Conversation
WalkthroughThis update introduces a mechanism to skip executing certain actions if the whitelist or blocklist of selected apps and domains has not changed. It achieves this by adding a comparison function for Changes
Sequence Diagram(s)sequenceDiagram
participant MonitorExtension
participant Action
participant Shared
MonitorExtension->>MonitorExtension: getCurrentWhitelist()
MonitorExtension->>MonitorExtension: getCurrentBlocklist()
loop For each action
MonitorExtension->>Action: Extract skipIfWhitelistOrBlacklistIsUnchanged flag
MonitorExtension->>Shared: shouldExecuteAction(..., skipIfWhitelistOrBlacklistIsUnchanged, originalWhitelist, originalBlocklist)
alt Whitelist/Blocklist unchanged and skip flag set
Shared-->>MonitorExtension: Return false (skip action)
else
Shared-->>MonitorExtension: Return true (execute action)
end
end
Poem
🪧 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: 9
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (5)
README.md(8 hunks)packages/react-native-device-activity/ios/Shared.swift(3 hunks)packages/react-native-device-activity/package.json(1 hunks)packages/react-native-device-activity/src/ReactNativeDeviceActivity.types.ts(1 hunks)packages/react-native-device-activity/targets/ActivityMonitorExtension/DeviceActivityMonitorExtension.swift(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/react-native-device-activity/ios/Shared.swift (1)
packages/react-native-device-activity/src/index.ts (1)
symmetricDifference(249-259)
🪛 LanguageTool
README.md
[typographical] ~18-~18: It seems that a comma is missing.
Context: ... Cases ## Handle permissions To block apps you need to request screen time permiss...
(IN_ORDER_TO_VB_COMMA)
[style] ~68-~68: As an alternative to the over-used intensifier ‘quite’, consider replacing this phrase.
Context: .... - The activitySelection tokens can be quite large (especially if you use includeEntireCat...
(EN_WEAK_ADJECTIVE)
[uncategorized] ~118-~118: A comma might be missing here.
Context: ... need different schedules for different days for example) you might need multiple mo...
(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
[uncategorized] ~118-~118: A comma might be missing here.
Context: ...schedules for different days for example) you might need multiple monitors. There...
(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
[typographical] ~122-~122: It seems that a comma is missing.
Context: ...se case. ## Block the shield To block apps you can do it directly from your code. ...
(IN_ORDER_TO_VB_COMMA)
[uncategorized] ~162-~162: Possible missing article found.
Context: ... sending web requests or notifications. Easiest way to explore this is exploring this w...
(AI_HYDRA_LEO_MISSING_THE)
[grammar] ~248-~248: Use “the” before the superlative.
Context: ...f the Shield UI/actions. We try to make a best guess here - prioritizing apps/web...
(THE_SUPERLATIVE)
[uncategorized] ~248-~248: Possible missing comma found.
Context: ...lay a shield specific for the Instagram selection that will take precedence over the less...
(AI_HYDRA_LEO_MISSING_COMMA)
🪛 SwiftLint (0.57.0)
packages/react-native-device-activity/ios/Shared.swift
[Warning] 1269-1269: if, for, guard, switch, while, and catch statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses
(control_statement)
[Warning] 1272-1272: if, for, guard, switch, while, and catch statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses
(control_statement)
[Warning] 1269-1269: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
[Warning] 1272-1272: Opening braces should be preceded by a single space and on the same line as the declaration
(opening_brace)
🔇 Additional comments (16)
packages/react-native-device-activity/package.json (1)
3-3: Package version increment looks good.The version number was incremented from 0.4.28 to 0.4.29, following semantic versioning conventions for this minor feature addition.
packages/react-native-device-activity/src/ReactNativeDeviceActivity.types.ts (1)
217-217: Well-placed optional flag for optimization.Adding the
skipIfWhitelistOrBlacklistIsUnchangedflag toCommonTypeParamsis a good optimization that allows consumers to avoid unnecessary actions when no changes have occurred to the whitelist or blocklist.packages/react-native-device-activity/targets/ActivityMonitorExtension/DeviceActivityMonitorExtension.swift (3)
68-69: Good implementation for capturing the original state.Capturing the original whitelist and blocklist at the beginning of action execution establishes a baseline for comparison, enabling the optimization feature to work properly.
91-91: Well-placed extraction of the flag.Correctly extracting the
skipIfWhitelistOrBlacklistIsUnchangedflag from the action dictionary maintains consistency with the TypeScript type definition.
104-106: Good parameter passing to the shouldExecuteAction function.Passing the original whitelist, blocklist, and the flag to the shouldExecuteAction function enables the comparison logic to work correctly.
packages/react-native-device-activity/ios/Shared.swift (2)
1236-1242: Good implementation of the equality check function.The
isEqualfunction efficiently compares two FamilyActivitySelection objects by using the symmetric difference operation and checking if the result is empty. This approach is elegant and maintains consistency with the existing codebase style.
1254-1256: Good parameter addition to the shouldExecuteAction function.Adding the new parameters to the shouldExecuteAction function signature maintains good code organization and provides all necessary data for the optimization feature.
README.md (9)
14-16: Addition of "Examples & Use Cases" section and permissions headerThe new section and subheader clearly organize the documentation for quick discovery.
23-27: Approve code snippet for requesting authorizationThe
useEffectexample correctly demonstrates how to request permissions on mount.
29-33: Approve code snippet for revoking authorizationThe
revokeAuthorizationexample is concise and clear.
37-39: Approve DeviceActivitySelectionView usage exampleThis snippet effectively shows how to render the native selection view and handle callbacks.
74-75: Approve import snippet for time trackingThe import example clearly shows the module usage.
80-80: Approve monitoring activity name exampleUsing
"TimeTrackingActivity"helps illustrate naming conventions.
97-97: Approve event listener exampleThe listener setup is clearly described and accurately demonstrates usage.
116-117: Approve notes introductionThe “Some things worth noting here:” heading effectively segments additional tips.
136-144: Approve BlockAfter10Minutes monitoring exampleThe snippet clearly illustrates how to set up an event with blocking actions.
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: 2
♻️ Duplicate comments (1)
packages/react-native-device-activity/ios/Shared.swift (1)
1269-1277: Implementation of skip logic looks good.The code correctly implements the logic for skipping actions when the whitelist and blocklist haven't changed.
The style has been improved according to previous review comments, with proper spacing and removal of unnecessary parentheses.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (1)
packages/react-native-device-activity/ios/Shared.swift(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/react-native-device-activity/ios/Shared.swift (1)
packages/react-native-device-activity/src/index.ts (1)
symmetricDifference(249-259)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 5
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (1)
README.md(8 hunks)
🔇 Additional comments (3)
README.md (3)
14-16: Approve Examples section additionThe new
# Examples & Use Casessection and the## Handle permissionssubheading align well with the existing structure and improve discoverability of usage guidance.
35-35: Approve Select Apps section headerThe
## Select Apps to trackheading clearly introduces the next usage example and follows the existing documentation style.
256-259: 🧹 Nitpick (assertive)Ensure bullet capitalization consistency
The bullet list mixes lowercase and uppercase starts. Align them by capitalizing the first word of each item, e.g.:
- familyActivitySelectionId mapping. This makes it possible for us to tie a familyActivitySelection token to an id that we can reuse and refer to at a later stage. + FamilyActivitySelectionId mapping. This makes it possible for us to tie a familyActivitySelection token to an id that we can reuse and refer to at a later stage.Likely an incorrect or invalid review comment.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Lite
📒 Files selected for processing (1)
packages/react-native-device-activity/package.json(1 hunks)
🔇 Additional comments (2)
packages/react-native-device-activity/package.json (2)
3-3: Version bump looks correct.
The package version has been updated from0.4.28to0.4.30to reflect the new flag and documentation changes.
3-3: Verify version consistency in native modules.
Please ensure that this version bump is echoed in your iOS Podspec, Android Gradle metadata, and any other build or distribution artifacts (e.g., CocoaPods, Maven Central).
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 3
♻️ Duplicate comments (4)
README.md (4)
123-123: Clarify programmatic blocking phrasing
Instead of “To block apps, you can do it directly from your code.”, consider:- To block apps, you can do it directly from your code. + To block apps programmatically, call the `blockSelection` method:
257-258: 🧹 Nitpick (assertive)Wrap code-like identifiers and fix casing
In the Data model bullets, wrap code keys in backticks and correct “userDefaults” to “UserDefaults” for consistency:- Prefixed like actions*for*${goalId} in userDefaults. + Prefixed like `actionsFor${goalId}` in UserDefaults. - Prefixed like events_${goalId} in userDefaults. + Prefixed like `events_${goalId}` in UserDefaults.
153-155:⚠️ Potential issueFix missing property assignment in action example
Theactionsobject is missing a key–value pair forfamilyActivitySelectionId. It should be something like:- { - type: "blockSelection", - familyActivitySelectionId, - } + { + type: "blockSelection", + familyActivitySelectionId: selectionId, + }
119-119: 🧹 Nitpick (assertive)Add commas around “for example”
In the parenthetical phrase, insert commas around “for example” for readability:- Depending on your use case (if you need different schedules for different days for example) you might need multiple monitors. + Depending on your use case (if you need different schedules for different days, for example), you might need multiple monitors.
Summary by CodeRabbit