-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[Redux Toolkit Migration] prefsSlice #4127
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
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged No assets were unchanged |
c33712b
to
0ae8b6d
Compare
200b0fc
to
2384069
Compare
5cbdb7d
to
582138a
Compare
2384069
to
5e0cf64
Compare
582138a
to
f0e15a2
Compare
5e0cf64
to
67df0f6
Compare
f0e15a2
to
1e4d9a1
Compare
67df0f6
to
3de3bba
Compare
1e4d9a1
to
af70553
Compare
3de3bba
to
b648b01
Compare
af70553
to
389b7ae
Compare
6c28206
to
49c15a1
Compare
389b7ae
to
a42f2b3
Compare
49c15a1
to
532232b
Compare
a42f2b3
to
43b6e4e
Compare
532232b
to
e1dacf3
Compare
43b6e4e
to
29faba1
Compare
e1dacf3
to
b58a227
Compare
29faba1
to
63a022d
Compare
b58a227
to
28c5c8f
Compare
63a022d
to
65641d0
Compare
28c5c8f
to
86bbe73
Compare
d6b3604
to
6a8610e
Compare
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
🧹 Nitpick comments (4)
packages/loot-core/src/client/prefs/prefsSlice.ts (4)
1-4
: Avoid ignoring restricted imports in loot-core.
The file explicitly disables the no-restricted-imports lint rule for@actual-app/web
, suggesting this is unintentional. To prevent issues when reorganizing the codebase, consider removing or refactoring this import rather than disabling the lint rule.
29-63
: Refine conditional check using optional chaining.
In line 36, the code checks bothprefs && prefs.id
. This can be simplified using optional chaining, which also reduces potential null/undefined checks.Example fix:
-if (prefs && prefs.id && !currentPrefs) { +if (prefs?.id && !currentPrefs) { dispatch(closeModal()); }🧰 Tools
🪛 Biome (1.9.4)
[error] 36-36: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
76-89
: Ensure handling of null or undefined fields in global prefs.
In previous feedback, type errors arose when certain fields likemaxMonths
orlanguage
returned null from the API. IfGlobalPrefs
strictly requires non-null types, consider providing default values or performing a shape transformation before dispatching.Would you like help implementing fallback logic?
158-170
: Consider adding tests for new thunks and reducers.
Although these actions and reducers look correct, thorough test coverage can help prevent regressions. You may want to add unit tests or integration tests verifying each new thunk and merge reducer’s behavior under various scenarios.Would you like me to open a new issue or draft example tests for each action?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
upcoming-release-notes/4127.md
is excluded by!**/*.md
📒 Files selected for processing (25)
packages/desktop-client/src/browser-preload.browser.js
(1 hunks)packages/desktop-client/src/components/App.tsx
(1 hunks)packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
(1 hunks)packages/desktop-client/src/components/settings/index.tsx
(1 hunks)packages/desktop-client/src/global-events.ts
(1 hunks)packages/desktop-client/src/hooks/useGlobalPref.ts
(2 hunks)packages/desktop-client/src/hooks/useMetadataPref.ts
(2 hunks)packages/desktop-client/src/hooks/useSyncedPref.ts
(2 hunks)packages/desktop-client/src/hooks/useSyncedPrefs.ts
(2 hunks)packages/desktop-client/src/index.tsx
(2 hunks)packages/desktop-electron/index.ts
(1 hunks)packages/loot-core/src/client/actions/index.ts
(0 hunks)packages/loot-core/src/client/actions/prefs.ts
(0 hunks)packages/loot-core/src/client/actions/user.ts
(1 hunks)packages/loot-core/src/client/app/appSlice.ts
(1 hunks)packages/loot-core/src/client/budgets/budgetsSlice.ts
(1 hunks)packages/loot-core/src/client/prefs/prefsSlice.ts
(1 hunks)packages/loot-core/src/client/reducers/index.ts
(0 hunks)packages/loot-core/src/client/reducers/prefs.ts
(0 hunks)packages/loot-core/src/client/shared-listeners.ts
(1 hunks)packages/loot-core/src/client/state-types/index.d.ts
(1 hunks)packages/loot-core/src/client/state-types/prefs.d.ts
(0 hunks)packages/loot-core/src/client/store/index.ts
(3 hunks)packages/loot-core/src/client/store/mock.ts
(2 hunks)packages/loot-core/src/server/preferences/app.ts
(5 hunks)
💤 Files with no reviewable changes (5)
- packages/loot-core/src/client/reducers/index.ts
- packages/loot-core/src/client/actions/index.ts
- packages/loot-core/src/client/state-types/prefs.d.ts
- packages/loot-core/src/client/actions/prefs.ts
- packages/loot-core/src/client/reducers/prefs.ts
🚧 Files skipped from review as they are similar to previous changes (19)
- packages/loot-core/src/client/store/mock.ts
- packages/loot-core/src/client/app/appSlice.ts
- packages/desktop-client/src/hooks/useSyncedPref.ts
- packages/desktop-client/src/components/App.tsx
- packages/loot-core/src/client/budgets/budgetsSlice.ts
- packages/desktop-client/src/index.tsx
- packages/desktop-client/src/components/settings/index.tsx
- packages/desktop-client/src/global-events.ts
- packages/loot-core/src/client/shared-listeners.ts
- packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
- packages/loot-core/src/client/state-types/index.d.ts
- packages/loot-core/src/server/preferences/app.ts
- packages/desktop-client/src/browser-preload.browser.js
- packages/loot-core/src/client/store/index.ts
- packages/desktop-client/src/hooks/useGlobalPref.ts
- packages/loot-core/src/client/actions/user.ts
- packages/desktop-client/src/hooks/useMetadataPref.ts
- packages/desktop-client/src/hooks/useSyncedPrefs.ts
- packages/desktop-electron/index.ts
🧰 Additional context used
🧠 Learnings (1)
packages/loot-core/src/client/prefs/prefsSlice.ts (1)
Learnt from: MatissJanis
PR: actualbudget/actual#3544
File: packages/loot-core/src/client/state-types/prefs.d.ts:13-18
Timestamp: 2024-11-10T16:45:31.225Z
Learning: When action types like `SetPrefsAction` are updated with new properties, ensure that reducers are correctly handling these properties before suggesting a potential issue.
🪛 Biome (1.9.4)
packages/loot-core/src/client/prefs/prefsSlice.ts
[error] 36-36: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: build (windows-latest)
- GitHub Check: build (ubuntu-latest)
- GitHub Check: Analyze
- GitHub Check: Wait for Netlify build to finish
🔇 Additional comments (3)
packages/loot-core/src/client/prefs/prefsSlice.ts (3)
96-106
: Validate onSaveGlobalPrefs callback usage.
TheonSaveGlobalPrefs
callback is optional. Ensure calling code checks for any errors thrown during thesaveGlobalPrefs
process, and confirm that expected side-effects in the callback run only after a successful save.
112-125
: Confirm concurrency safety when saving multiple synced prefs.
The loop concurrently sends multiplepreferences/save
requests. While this is likely fine, confirm the backend can handle simultaneous updates without partial saves, or add error handling if a single request fails.
137-156
: Looks good!
The reducers are cleanly defined, allowing atomic merges of preferences. This approach ensures that local, global, and synced prefs remain distinct, minimizing potential overwrites.
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.
All good :)
actions/account.ts
/reducers/account.ts
->accounts/accountsSlice.ts
[Redux Toolkit Migration] accountsSlice #4012actions/queries.ts
/reducers/queries.ts
->queries/queriesSlice.ts
[Redux Toolkit Migration] queriesSlice #4016actions/app.ts
/reducers/app.ts
->app/appSlice.ts
[Redux Toolkit Migration] appSlice #4018actions/budgets.ts
/reducers/budgets.ts
->budgets/budgetsSlice.ts
[Redux Toolkit Migration] budgetsSlice #4114actions/modals.ts
/reducers/modals.ts
->modals/modalsSlice.ts
[Redux Toolkit Migration] modalsSlice #4119actions/notifications.ts
/reducers/notifications.ts
->notifications/notificationsSlice.ts
[Redux Toolkit Migration] notificationsSlice #4126actions/prefs.ts
/reducers/prefs.ts
->prefs/prefsSlice.ts
actions/user.ts
/reducers/user.ts
->users/usersSlice.ts