Skip to content
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

Make accountslice take an array #289

Merged
merged 2 commits into from
Jul 24, 2023
Merged

Make accountslice take an array #289

merged 2 commits into from
Jul 24, 2023

Conversation

ryutamago
Copy link
Contributor

@ryutamago ryutamago commented Jul 23, 2023

Make Accounts slice take an array

This is a refactoring PR part of #288
We make the accountSlice.add action more generic by taking an array of accounts

Types of changes

Put an x in the boxes that apply

  • Bugfix
  • New feature
  • Refactor
  • Breaking change
  • Documentation Update

@ryutamago ryutamago marked this pull request as draft July 23, 2023 09:29
@ryutamago ryutamago marked this pull request as ready for review July 24, 2023 04:41
@@ -38,10 +38,8 @@ const accountsSlice = createSlice({
state.items = newAccounts;
delete state.seedPhrases[fingerPrint];
},
add: (state, { payload }: { type: string; payload: ImplicitAccount | ImplicitAccount[] }) => {
const accounts = Array.isArray(payload) ? payload : [payload];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if passing in just one object was a problem but I'd write it as state.items = concatUnique(state.items, [payload].flat()); WDYT?

Copy link
Contributor Author

@ryutamago ryutamago Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i noticed there was no other places in the codebase that passes in a single item other than the tests so i think it's better to keep the API simple like this

@ryutamago ryutamago merged commit 5a60928 into main Jul 24, 2023
1 check passed
@ryutamago ryutamago deleted the accounts-slice-list branch July 24, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants