-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
fix(dashboard): welcome banner not closing for pocket user #3189
Conversation
Warning Rate limit exceeded@rhahao has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 29 minutes and 10 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (26)
WalkthroughThis pull request introduces several modifications across various components and hooks in the application. Key changes include updates to type definitions in Changes
Possibly related PRs
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 (
|
✅ Deploy Preview for staging-organized ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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: 4
🧹 Outside diff range and nitpick comments (4)
src/pages/persons/all_persons/useAllPersons.tsx (1)
26-31
: Consider handling loading and error states fromuseQuery
Currently, the code does not handle loading or error states from the
useQuery
hook. DestructureisLoading
,isError
, anderror
fromuseQuery
to provide feedback to users or to handle errors appropriately.src/features/congregation/settings/import_export/export/useExport.tsx (1)
104-104
: Consider keeping JSON formatting for backup filesRemoving formatting options from
JSON.stringify
makes the backup file less readable for debugging purposes.Consider keeping the formatting for better readability:
- const prettyJsonData = JSON.stringify(backupData); + const prettyJsonData = JSON.stringify(backupData, null, 2);src/layouts/root_layout/index.tsx (1)
6-26
: Improve import organizationThe reorganization of imports from centralized to direct paths improves maintainability and module independence. However, consider grouping related imports together (e.g., all feature imports, all component imports) for better readability.
src/layouts/navbar/index.tsx (1)
28-32
: Improve import organizationSimilar to the root layout, the imports have been reorganized from centralized to direct paths. Consider grouping related imports together for better maintainability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (25)
src/definition/api.ts
(2 hunks)src/features/app_start/pocket/signup/useSignup.tsx
(1 hunks)src/features/congregation/settings/import_export/export/useExport.tsx
(5 hunks)src/features/demo/start/index.tsx
(2 hunks)src/features/index.ts
(0 hunks)src/features/persons/app_user_profile/index.tsx
(3 hunks)src/features/persons/app_user_profile/useAppUserProfile.tsx
(1 hunks)src/features/persons/enrollments/index.tsx
(2 hunks)src/features/persons/privileges/index.tsx
(2 hunks)src/layouts/navbar/index.tsx
(1 hunks)src/layouts/root_layout/index.tsx
(1 hunks)src/pages/dashboard/congregation/index.tsx
(1 hunks)src/pages/dashboard/meeting_materials/index.tsx
(1 hunks)src/pages/dashboard/meetings/index.tsx
(1 hunks)src/pages/dashboard/ministry/index.tsx
(1 hunks)src/pages/dashboard/persons/index.tsx
(1 hunks)src/pages/dashboard/reports/index.tsx
(1 hunks)src/pages/meeting_materials/public_talks_list/index.tsx
(1 hunks)src/pages/meetings/midweek/index.tsx
(1 hunks)src/pages/meetings/weekend/index.tsx
(1 hunks)src/pages/persons/all_persons/index.tsx
(1 hunks)src/pages/persons/all_persons/useAllPersons.tsx
(2 hunks)src/pages/persons/person_details/index.tsx
(3 hunks)src/pages/persons/person_details/usePersonDetails.tsx
(3 hunks)src/services/dexie/assignment.ts
(2 hunks)
💤 Files with no reviewable changes (1)
- src/features/index.ts
✅ Files skipped from review due to trivial changes (5)
- src/features/demo/start/index.tsx
- src/pages/dashboard/persons/index.tsx
- src/pages/dashboard/meetings/index.tsx
- src/pages/dashboard/meeting_materials/index.tsx
- src/pages/meeting_materials/public_talks_list/index.tsx
🔇 Additional comments (18)
src/pages/persons/all_persons/index.tsx (1)
14-16
: LGTM! Good improvement in import organization.
The direct imports from specific feature paths instead of the index file is a good practice that improves maintainability and potentially helps with tree-shaking.
Let's verify the bundle size impact:
✅ Verification successful
Based on the shell script results, I can now generate the final response:
Import changes are properly aligned with the codebase structure
The direct imports from specific feature paths (@features/persons/list
, @features/persons/filter
, @features/persons/search
) are consistent with the codebase organization, as evidenced by:
- No other files importing from
@features/index
- Each feature has its own dedicated directory with an index file
- The persons feature components are properly organized in their respective directories:
src/features/persons/list/index.tsx
src/features/persons/filter/index.tsx
src/features/persons/search/index.tsx
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for potential bundle size impact
# Look for any other index files that might need similar restructuring
# Check for other potential index files with similar export patterns
rg -l "export \{ .+ \} from" --type ts --type tsx
# Look for other imports from @features/index to ensure consistency
rg "@features/index" --type ts --type tsx
Length of output: 149
Script:
#!/bin/bash
# Let's try without file type filters since tsx isn't recognized
# Check for other potential index files with similar export patterns
rg -l "export \{ .+ \} from"
# Look for other imports from @features/index
rg "@features/index"
# Also check for the existence and content of any index files in the features directory
fd "index\.(ts|tsx|js|jsx)$" src/features
# If we find any index files, let's look at their content
fd "index\.(ts|tsx|js|jsx)$" src/features -x cat {}
Length of output: 67531
src/pages/persons/person_details/usePersonDetails.tsx (1)
17-17
: LGTM!
The integration of isConnected
into the hook is correctly implemented.
Also applies to: 48-48
src/features/persons/app_user_profile/index.tsx (1)
Line range hint 12-43
: Component properly updates UI based on user state
The component correctly adapts its display and behavior based on the presence of the user
object, enhancing user experience.
src/features/persons/enrollments/index.tsx (1)
9-9
: LGTM! Component rename improves clarity.
The rename from Enrollments
to PersonEnrollments
provides better context and aligns with the component's specific purpose.
Let's verify that all imports of this component have been updated:
Also applies to: 77-77
✅ Verification successful
Component rename is correctly implemented across the codebase
The search results confirm that the component rename from Enrollments
to PersonEnrollments
is properly reflected in all imports. The only references to the new PersonEnrollments
component are in:
- The component definition file (
src/features/persons/enrollments/index.tsx
) - Its usage in the person details page (
src/pages/persons/person_details/index.tsx
)
All other occurrences of "Enrollments" in the codebase are unrelated to this component (they refer to different components like PrivilegesEnrollments
or are part of variable names and data structures).
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining references to the old component name
rg "Enrollments" --type tsx --type ts
Length of output: 65
Script:
#!/bin/bash
# Search for any remaining references to the old component name using ripgrep
# Note: Using just file extensions instead of file types
rg "Enrollments" -g "*.tsx" -g "*.ts"
Length of output: 1559
src/features/persons/privileges/index.tsx (1)
9-9
: LGTM! Consistent component naming.
The rename from Privileges
to PersonPrivileges
maintains consistency with other person-related components.
Let's verify that all imports of this component have been updated:
Also applies to: 79-79
✅ Verification successful
All references to the renamed component have been properly updated
The verification shows that all occurrences of "Privileges" in the codebase are either:
- The new
PersonPrivileges
component name itself and its import - Related but different identifiers (like
usePrivileges
hook) - Unrelated usage in the services layer (
personEndActivePrivileges
)
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining references to the old component name
rg "Privileges\s" --type tsx --type ts
Length of output: 68
Script:
#!/bin/bash
# Search for any remaining references to the old component name using ripgrep
# Note: Using just file extensions instead of file types
rg "Privileges\s" -g "*.tsx" -g "*.ts"
Length of output: 655
src/pages/persons/person_details/index.tsx (3)
9-18
: LGTM: Improved import organization
The granular imports from @features/persons
improve code maintainability by making dependencies explicit and easier to track.
89-89
: Verify component rename impact
The rename from PersonAssignment
to PersonAssignments
suggests a change in data handling. Let's verify all references are updated.
✅ Verification successful
Component naming is consistent across the codebase
The search results show that PersonAssignments
is being used consistently throughout the codebase. There are two related but distinct components:
PersonAssignments
in@features/persons/assignments
PersonAssignmentsHistory
in@features/persons/assignments_history
Both components are properly imported and used in person_details/index.tsx
. There's no evidence of any remaining references to a singular "PersonAssignment" component, indicating the naming is consistent.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining references to old component name
rg "PersonAssignment[^s]"
Length of output: 27
Script:
#!/bin/bash
# Let's try a broader search to understand the component usage
rg "PersonAssignment" -A 2
Length of output: 1322
Script:
#!/bin/bash
# Also search for component definition
ast-grep --pattern 'const PersonAssignment'
Length of output: 45
Script:
#!/bin/bash
# Check git history for recent renames
git log --oneline -S "PersonAssignment" --since="1 month ago"
Length of output: 0
25-25
: Verify access control implementation
The addition of isAdmin
and isConnected
checks suggests a security enhancement. However, let's verify this aligns with the access control requirements.
Also applies to: 27-27
✅ Verification successful
Let me gather more context about the access control implementation by checking the useCurrentUser
hook and related components.
Access control implementation verified and properly layered
The access control implementation for the PersonAppUserProfile component follows a secure pattern with multiple conditions:
- Component is only rendered when user is an admin (
isAdmin
) - Requires an active connection (
isConnected
) - Not available for new persons (
!isNewPerson
)
The broader access control using isPersonEditor
and isAdmin
is consistently implemented across the codebase, particularly in congregation and person management features.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other instances of isAdmin checks in person-related components
rg -A 3 "isAdmin.*PersonAppUserProfile"
# Search for access control patterns in person features
ast-grep --pattern 'const { $$$, isAdmin } = useCurrentUser();'
Length of output: 1604
Script:
#!/bin/bash
# Check the implementation of useCurrentUser hook
ast-grep --pattern 'export function useCurrentUser() {
$$$
}'
# Check PersonAppUserProfile component implementation
ast-grep --pattern 'function PersonAppUserProfile() {
$$$
}'
# Look for other access control patterns in person details
rg -A 3 "isPersonEditor|isConnected" src/pages/persons/person_details/
Length of output: 1988
src/pages/meetings/weekend/index.tsx (1)
9-9
: LGTM: Component organization improvement
The imports have been moved to dedicated feature folders, improving code organization.
Also applies to: 13-13
src/features/congregation/settings/import_export/export/useExport.tsx (1)
88-88
: Verify data model compatibility
The addition of assignments and week types to the export data structure needs verification for backward compatibility.
Also applies to: 100-100
✅ Verification successful
The initial search revealed backup-related files but we need to verify the data model and import functionality specifically. These new commands will help us understand:
- The backup data type structure
- The import functionality implementation
- How assignments are handled during import
This will help us determine if the addition of assignments to the export structure maintains backward compatibility.
The previous search revealed the backup data type definitions, but we need to understand:
- How the import functionality handles assignments
- How assignments are processed during export
- Any data transformations that might maintain backward compatibility
This will help us determine if the addition of assignments to the export structure is safely handled during import.
The previous search showed the export functionality for assignments is simple and only includes basic properties (code and name). We need to verify:
- How the import functionality handles assignments
- The assignment data structure/types
- Any version or compatibility checks during import
This will help us determine if there are any compatibility concerns with the assignment data structure.
Based on the gathered information, I can now provide the final response:
Export structure changes maintain backward compatibility
The addition of assignments to the export data structure is safe because:
- The export includes version information (
PACKAGE_VERSION
) in the payload - The assignments export is minimal, only including basic properties (
code
andassignment_type_name
) - The backup data type definitions (
BackupDataType
) show assignments are optional fields
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for import functionality to verify compatibility
rg -A 5 "import.*backup"
# Check for existing backup format documentation
fd -g "*backup*.md" -g "*export*.md"
Length of output: 27271
Script:
#!/bin/bash
# Let's check the backup data type definition and import functionality
ast-grep --pattern 'type BackupDataType = {
$$$
}'
# Search for import functionality implementation
ast-grep --pattern 'const $_ = async ($$$) => {
$$$
import $$$
$$$
}'
# Check for any existing assignments handling in backup/import
rg -A 5 "assignments.*import"
Length of output: 4533
Script:
#!/bin/bash
# Let's check the import functionality implementation
rg -A 10 "handleImport.*="
# Check for assignments handling in the export functionality
rg -A 10 "handleGetAssignments.*="
# Check for any data transformation during import/export
rg -A 5 "transform.*assignments"
Length of output: 1122
Script:
#!/bin/bash
# Let's check the import functionality implementation
ast-grep --pattern 'const handleImport = ($$$) => {
$$$
}'
# Check for assignment-related types and interfaces
rg -A 5 "type.*Assignment"
rg -A 5 "interface.*Assignment"
# Check for any version or compatibility checks in import/export
rg -A 5 "version.*import|compatibility.*import"
Length of output: 49380
src/definition/api.ts (2)
244-244
: LGTM! Non-breaking change to user type
The addition of optional createdAt
field is backward compatible.
29-29
: Verify timestamp format consistency across the application
The change from number
to string
for last_seen
suggests a shift in timestamp representation. Ensure all consumers of this type are updated to handle string timestamps correctly.
✅ Verification successful
Let's broaden our search to understand the usage context of last_seen
and SessionResponseType
in the codebase. This will help us verify if the type change impacts any date/time handling logic.
Type change to string is correctly handled across the codebase
The change from number
to string
for last_seen
is safe as all consumers are already handling it as a string:
- In
useAppUserProfile.tsx
, it's used withlocaleCompare
for sorting and parsed withnew Date(last_seen)
- In
useSessionItem.tsx
, it's parsed usingnew Date(session.last_seen)
- No direct numeric operations are performed on the value
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for usages of SessionResponseType.last_seen to verify correct handling
ast-grep --pattern 'last_seen: $_'
rg -A 2 'last_seen.*SessionResponseType'
Length of output: 79
Script:
#!/bin/bash
# Search for usages of last_seen in the codebase
rg "last_seen" -A 3 -B 1
# Search for SessionResponseType definition and usage
rg "SessionResponseType" -A 5 -B 1
# Search for any date/time parsing or formatting of last_seen
rg "last_seen.*(?:parse|format|Date|moment|dayjs)" -A 2
Length of output: 8330
src/features/app_start/pocket/signup/useSignup.tsx (1)
105-105
: LGTM! Fix for welcome banner persistence
Setting cong_settings.cong_new
to false
during signup should prevent the welcome banner from appearing unnecessarily for pocket users.
✅ Verification successful
Let me gather more information about the welcome banner implementation to verify this change properly.
Let me search specifically for the welcome banner implementation and its relationship with settings.
Let me check the initial setup component to understand how the welcome state is handled.
Based on the gathered evidence, I can now provide the final response:
Setting cong_new
to false
is the correct approach for preventing the welcome banner
The code review confirms this change is correct because:
- The
useInitialSetup
hook controls the welcome/setup flow based oncong_settings.cong_new
- The same pattern of setting
cong_new: false
is consistently used across other signup/authentication flows - The initial setup is only shown when
isNew && isAdmin
is true, whereisNew
is derived fromcong_settings.cong_new
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify welcome banner's dependency on cong_new setting
rg -A 5 "cong_new.*welcome.*banner"
ast-grep --pattern 'cong_settings.cong_new'
Length of output: 165
Script:
#!/bin/bash
# Search for welcome banner related code and its conditions
rg -A 5 "welcome.*banner|WelcomeBanner"
# Search for any other occurrences of cong_new
rg "cong_new"
# Look for settings related to new user or welcome states
ast-grep --pattern 'const $_ = useSelector((state: RootState) => state.settings)'
Length of output: 2079
Script:
#!/bin/bash
# Search for files containing WelcomeBanner component
fd -e tsx -e jsx WelcomeBanner
# Search for welcome banner component implementation
ast-grep --pattern 'const WelcomeBanner = $_'
# Search for isNew usage in components
ast-grep --pattern 'const isNew = $_'
Length of output: 240
Script:
#!/bin/bash
# Check the implementation of initial setup component
cat src/features/dashboard/initial_setup/useInitialSetup.tsx
# Look for any components that might render based on isNew
rg -A 5 "isNew.*render|isNew.*show|isNew.*display"
Length of output: 1018
src/services/dexie/assignment.ts (1)
146-168
: LGTM! Consistent naming pattern for weekend meeting assignments
The weekend meeting chairman and prayer assignment names follow the same clear pattern of combining role and meeting type.
src/pages/dashboard/ministry/index.tsx (1)
9-11
: Import refactoring appears unrelated to PR objective
While the import path changes improve code organization, they seem unrelated to fixing the welcome banner closing issue for pocket users. Please clarify how these changes contribute to the PR's objective.
Let's verify if there are any welcome banner related files that should be modified instead:
src/pages/dashboard/reports/index.tsx (1)
9-10
: Scope of changes exceeds PR objective
These import refactoring changes, while beneficial for code organization, appear to be outside the scope of fixing the welcome banner closing issue. Consider separating these refactoring changes into a different PR to maintain focused changesets.
Let's check if there are any welcome banner components that import from @features/index:
src/pages/dashboard/congregation/index.tsx (1)
10-11
: Consider separating refactoring from bug fix
The import path changes across multiple files suggest a broader refactoring effort. However, the PR's title and objective specifically mention fixing the welcome banner closing functionality for pocket users. These changes don't appear to address that issue.
Let's verify if we're missing any welcome banner related changes:
src/layouts/navbar/index.tsx (1)
Line range hint 1-391
: Verify PR objective alignment
The changes in this file appear to be refactoring imports without addressing the stated PR objective of fixing the welcome banner closure for pocket users. Please verify if there are missing changes or if these changes are prerequisites for the fix.
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 (1)
src/features/app_start/vip/startup/useStartup.tsx (1)
Line range hint
150-171
: LGTM! Consider refactoring for maintainability.The logic for handling authenticated users with missing congregation setup looks correct. However, the
runStartupCheck
function has grown quite complex with deep nesting levels.Consider extracting the congregation setup logic into a separate function for better maintainability:
+ const handleCongregationSetup = ( + result: { cong_id: string; cong_master_key?: string; cong_access_code?: string }, + masterKeyNeeded: boolean + ) => { + setCongID(result.cong_id); + + if (masterKeyNeeded && result.cong_master_key?.length === 0) { + setCurrentStep(1); + } + + if ( + masterKeyNeeded && + result.cong_master_key?.length > 0 && + result.cong_access_code?.length === 0 + ) { + setCurrentStep(2); + } + + setIsLoading(false); + setIsStart(false); + setCongCreate(true); + }; // In runStartupCheck: - if ( - isAuthenticated && - congName.length === 0 && - (remoteMasterKey.length === 0 || remoteAccessCode.length === 0) - ) { - setCongID(result.cong_id); - - if (masterKeyNeeded && remoteMasterKey.length === 0) { - setCurrentStep(1); - } - - if ( - masterKeyNeeded && - remoteMasterKey.length > 0 && - remoteAccessCode.length === 0 - ) { - setCurrentStep(2); - } - - setIsLoading(false); - setIsStart(false); - setCongCreate(true); - return; - } + if ( + isAuthenticated && + congName.length === 0 && + (remoteMasterKey.length === 0 || remoteAccessCode.length === 0) + ) { + handleCongregationSetup(result, masterKeyNeeded); + return; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
src/features/app_start/vip/startup/useStartup.tsx
(1 hunks)src/features/persons/app_user_profile/useAppUserProfile.tsx
(1 hunks)src/services/dexie/assignment.ts
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/services/dexie/assignment.ts
🔇 Additional comments (7)
src/features/persons/app_user_profile/useAppUserProfile.tsx (6)
1-18
: LGTM! Hook renaming improves clarity
The rename from usePersonAppPersonProfile
to useAppUserProfile
makes the hook name more concise while maintaining clarity about its purpose.
19-24
: LGTM! Proper memoization of user lookup
The memoization is correctly implemented with appropriate dependencies, and the user lookup logic is sound.
33-35
: Fix potential incorrect sorting of sessions by last_seen
timestamp
Sorting dates using localeCompare
on strings may not yield correct chronological order.
40-52
: LGTM! Well-structured user description logic
The implementation properly handles all cases with appropriate translations and date formatting.
54-61
: LGTM! Clean navigation logic
The navigation logic is clear and handles both registered and unregistered user cases appropriately.
63-66
: LGTM! Clean and focused exports
The hook exports exactly what's needed for the welcome banner functionality.
src/features/app_start/vip/startup/useStartup.tsx (1)
Line range hint 150-171
: Verify error handling for congregation setup.
The new congregation setup flow might need additional error handling for edge cases.
Let's verify the error handling in the codebase:
Quality Gate passedIssues Measures |
organized-app Run #1778
Run Properties:
|
Project |
organized-app
|
Branch Review |
main
|
Run status |
Passed #1778
|
Run duration | 00m 09s |
Commit |
0f505432e9: chore(persons): update sorting option to get last seen
|
Committer | rhahao |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
1
|
View all changes introduced in this branch ↗︎ |
🎉 This PR is included in version 3.4.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
No description provided.