-
Notifications
You must be signed in to change notification settings - Fork 31
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
Amount Preferences Fixes #140
base: development
Are you sure you want to change the base?
Amount Preferences Fixes #140
Conversation
This looks good to me, great job! However we should wait for |
Now the changes are isolated. |
export type Preferences = { | ||
sendPreference: Array<AmountPreference>; | ||
keepPreference?: Array<AmountPreference>; | ||
}; |
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.
This is an awesome PR!
If we do introduce breaking changed is on how the preference is passed, what do you guys think of getting rid of the (rather cumbersome?) format for the preference as sendPreference: [{ amount: 1, count: 3 }]
and instead use a pure array of numbers a la sendPreference: [1, 1, 1]
? I think I would prefer that.
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.
Probably a good idea. I think the original motive behind it was noble (not having an array with a billion useless 1s in it) but this is more practical.
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.
Really like this PR. We have to decide wether this should be a breaking change in the API or not. We could also deprecate the old method for setting the amount preference (see my comment).
preference?: Array<AmountPreference>; | ||
preference?: Preferences; |
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.
How about we deprecate preference
, do the new thing in a new option called outputAmounts
, and write a thin translation method that maps preference
to outputAmounts
, and issue a deprecation warning?
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.
I second this
Maybe this is out of scope for this PR but we should also get rid of this behavior of the lib where it overwrites Example: if (options?.preference) {
amount = options?.preference?.reduce((acc, curr) => acc + curr.amount * curr.count, 0);
} |
Fixes: #129
Changes
but from the amounts of the keyset instead.
PR Tasks
npm run test
--> no failing unit testsnpm run format