-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Redux Toolkit Migration] Use new Redux Toolkit configureStore API #4000
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
546d614
to
c53deaf
Compare
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 (largest 100 files by percent change)
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
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 No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
/update-vrt |
@@ -11,6 +11,7 @@ const currentUndoState: T.UndoState = { | |||
url: null, | |||
openModal: null, | |||
selectedItems: null, | |||
current: null, |
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.
Moved from redux state.app.lastUndoState
to here
@@ -8,6 +8,7 @@ export type UndoState = { | |||
name: string; | |||
items: Set<string>; | |||
} | null; | |||
current: unknown; |
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.
Moved from redux state.app.lastUndoState
to here
// Reset the state and only keep around things intentionally. This | ||
// blows away everything else | ||
state = { | ||
account: initialAccountState, |
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.
TS is complaining about the missing state properties so I have set them to initial states instead.
@@ -1,7 +1,7 @@ | |||
import type * as constants from '../constants'; | |||
|
|||
export type AccountState = { | |||
failedAccounts: Map<string, { type: string; code: string }>; | |||
failedAccounts: { [key: string]: { type: string; code: string } }; |
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.
Changed to object because redux toolkit complains that Map
is non-serializable
@@ -18,17 +16,6 @@ export function update(state = initialState, action: Action): AppState { | |||
...state, | |||
...action.state, | |||
}; | |||
case constants.SET_LAST_UNDO_STATE: |
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.
Removed from redux state and moved to loot-core/platform/client/undo
since redux toolkit is complaining that it's mutating in the reducer
state.lastUndoState.current = action.undoState; | ||
return state; | ||
|
||
case constants.SET_LAST_SPLIT_STATE: |
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.
Removed from redux state and moved to useSplitExpanded
since redux toolkit is complaining that it's mutating in the reducer
@@ -2,8 +2,8 @@ import * as constants from '../constants'; | |||
import type { Action } from '../state-types'; | |||
import type { AccountState } from '../state-types/account'; | |||
|
|||
const initialState: AccountState = { | |||
failedAccounts: new Map(), |
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.
Changed from Map to object since redux toolkit is complaining that Map is non-serializable
@@ -59,7 +59,7 @@ type SplitsStateContext = { | |||
const SplitsExpandedContext = createContext<SplitsStateContext>({ | |||
state: { | |||
mode: 'collapse', | |||
ids: new Set(), |
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.
Changed from Set to array since redux toolkit is complaining that Set is non-serializable
5b062e2
to
dd92cb3
Compare
Initial migration to redux-toolkit. This PR focuses on retrofitting the existing reducers to the newer redux toolkit APIs. We can work on converting them to redux slices in a future PR.
Aside from converting to the usage of typed
useAppDispatcher
anduseAppSelector
, I had to do some changes to theSET_LAST_UNDO_STATE
andSET_LAST_SPLIT_STATE
to prevent mutating the state in their reducers because redux toolkit now check for that.There are still some redux validation errors due to non-serializable values being on the the state e.g. modal callback functions. But I have disabled those checks temporarily until we can address them in a future PR.
configureStore
APISET_LAST_UNDO_STATE
,SET_LAST_SPLIT_STATE
)createSlice
APIcreateAsyncThunk
API