-
-
Notifications
You must be signed in to change notification settings - Fork 822
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
Using database for translations for cross-devices #2077
Using database for translations for cross-devices #2077
Conversation
WalkthroughThe recent changes enable storing user language preferences in the database instead of localStorage to support multiple devices. This includes updating GraphQL mutations ( Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI
participant Server
participant DB
User->>UI: Change language from dropdown
UI->>Server: GraphQL mutation with `appLanguageCode`
Server->>DB: Update user language setting
DB-->>Server: Acknowledge update
Server-->>UI: Confirm language update
UI->>i18n: Change language using `i18n.changeLanguage()`
Assessment against linked issues
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Our Pull Request Approval ProcessWe have these basic policies to make the approval process smoother for our volunteer team. Testing Your CodePlease make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:
The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
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.yaml
Review profile: CHILL
Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
Files selected for processing (5)
- src/GraphQl/Mutations/mutations.ts (3 hunks)
- src/components/ChangeLanguageDropdown/ChangeLanguageDropDown.tsx (1 hunks)
- src/index.tsx (2 hunks)
- src/screens/LoginPage/LoginPage.tsx (2 hunks)
- src/screens/MemberDetail/MemberDetail.tsx (2 hunks)
Additional comments not posted (9)
src/components/ChangeLanguageDropdown/ChangeLanguageDropDown.tsx (3)
6-8
: Imports look good.The new imports for
UPDATE_USER_MUTATION
anduseMutation
are correctly added and necessary for the new functionality.
21-21
: Retrieval ofuserId
looks good.The
userId
is correctly retrieved from local storage usinggetItem
.
22-22
: Usage ofuseMutation
looks good.The
useMutation
hook forUPDATE_USER_MUTATION
is correctly used and necessary for updating the user's language setting.src/index.tsx (2)
46-46
: Import statement looks good.The import statement for
i18n
is correctly modified.
50-55
: Setting theAccept-Language
header looks good.The
Accept-Language
header is correctly set based on the user's language preference usingi18n.language
.src/GraphQl/Mutations/mutations.ts (2)
Line range hint
100-114
:
Update toUPDATE_USER_MUTATION
looks good.The mutation is correctly updated to include
appLanguageCode
in the variables and input data.
190-190
: Update toLOGIN_MUTATION
looks good.The mutation is correctly updated to include
appLanguageCode
in the returned data.src/screens/MemberDetail/MemberDetail.tsx (1)
502-502
: Binding of selected language value looks good.The
<select>
element correctly binds the selected language value to the form state usingvalue={formState.appLanguageCode}
.src/screens/LoginPage/LoginPage.tsx (1)
294-294
: LGTM! But verifyappLanguageCode
presence and validity.The code change ensures that the application interface matches the user's language preference after login.
However, ensure that
loginData.login.appUserProfile.appLanguageCode
is always defined and valid.
src/components/ChangeLanguageDropdown/ChangeLanguageDropDown.tsx
Outdated
Show resolved
Hide resolved
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: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- src/components/ChangeLanguageDropdown/ChangeLanguageDropDown.tsx (1 hunks)
- src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.test.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/components/ChangeLanguageDropdown/ChangeLanguageDropDown.tsx
Additional comments not posted (5)
src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.test.tsx (5)
10-12
: Imports Approved.The new imports for
MockedProvider
,UPDATE_USER_MUTATION
, andStaticMockLink
are necessary for mocking the GraphQL mutation and are correctly imported.
22-40
: Mocks Approved.The
MOCKS
array correctly simulates the GraphQL mutation for updating the user's language preference.
42-42
: StaticMockLink Usage Approved.The
StaticMockLink
correctly uses theMOCKS
array and ensures the mocked data is used in the tests.
46-52
: Test Case Approved.The test case correctly verifies if the
ChangeLanguageDropDown
component renders properly.
Line range hint
80-124
:
Test Cases Approved.The test cases correctly verify the component's props, language cookie handling, and language change functionality.
Note:Deleted |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2077 +/- ##
===========================================
- Coverage 97.92% 97.91% -0.01%
===========================================
Files 232 231 -1
Lines 6208 6195 -13
Branches 1791 1788 -3
===========================================
- Hits 6079 6066 -13
Misses 118 118
Partials 11 11 ☔ View full report in Codecov by Sentry. |
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: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- src/components/ChangeLanguageDropdown/ChangeLanguageDropDown.tsx (1 hunks)
- src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.test.tsx (5 hunks)
Files skipped from review as they are similar to previous changes (2)
- src/components/ChangeLanguageDropdown/ChangeLanguageDropDown.tsx
- src/components/ChangeLanguageDropdown/ChangeLanguageDropdown.test.tsx
What kind of change does this PR introduce?
Feature: With this PR merge, now we will use the language from DB. So if you change the language in your profile, it will use that language on login (on any device)
Issue Number:
Fixes #2076
Did you add tests for your changes?
Yes
Snapshots/Videos:
N/A
If relevant, did you update the documentation?
NA
Summary
login
Does this PR introduce a breaking change?
No
Other information
Have you read the contributing guide?
Yes
Summary by CodeRabbit
New Features
Improvements
Code Quality