-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
random zap amounts #1263
random zap amounts #1263
Conversation
395c8c1
to
e83386a
Compare
adds an option to enable random zap amounts per stacker configurable in settings, you can enable this feature and provide an upper and lower range of your random zap amount
this has been bothering me since we aren't using eslint for linting
e83386a
to
4d57651
Compare
@@ -1,4 +1,4 @@ | |||
name: Eslint Check | |||
name: Lint Check |
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.
Just a nit because we don't actually use eslint.
@@ -101,7 +101,7 @@ export default function ItemAct ({ onClose, item, down, children, abortSignal }) | |||
return ( | |||
<Form | |||
initial={{ | |||
amount: me?.privates?.tipDefault || defaultTips[0], | |||
amount: defaultTipIncludingRandom(me?.privates) || defaultTips[0], |
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.
Honor random zap settings here, too.
@@ -67,11 +67,20 @@ export function DropdownItemUpVote ({ item }) { | |||
) | |||
} | |||
|
|||
export const nextTip = (meSats, { tipDefault, turboTipping }) => { | |||
export const defaultTipIncludingRandom = ({ tipDefault, tipRandom, tipRandomMin, tipRandomMax }) => |
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.
A reusable function for determining the next zap value that honors tipRandom
and tipDefault
@@ -540,8 +540,31 @@ export const actSchema = object({ | |||
act: string().required('required').oneOf(['TIP', 'DONT_LIKE_THIS']) | |||
}) | |||
|
|||
export const settingsSchema = object({ | |||
export const settingsSchema = object().shape({ |
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.
Had to do this for the cyclic dependency issue noted below
I think this is ready for review. Let me know of any feedback! |
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.
Sorry for the slow review. The only thing blocking is the sort of redundant boolean. Not a huge deal, but we already have so many columns.
(I'll want to clean up the UI of the zap accordion too, but given that involves zap undos too, I'll do that after merging.)
prisma/schema.prisma
Outdated
tipRandom Boolean @default(false) | ||
tipRandomMin Int? | ||
tipRandomMax Int? |
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 don't think we need the boolean if we can just check for null on min and max. I'd suggest we use a postgres range type too but prisma doesn't support it.
Ok, thank you for the feedback! FWIW, I went with the redundant Boolean so users could explicitly enable/disable the feature which I felt was a more clear pattern, and also so that users could disable the feature without wiping out their configured values. In any case, I can make the adjustments, hopefully in the next day or two :) |
I think the boolean in the UI does make sense. For the db, I'd just prefer the values. Toggling off an on wouldn't persist old values but I don't suspect that'd happen a lot. |
What are your thoughts on keeping I'm ok either way, but this idea occurred to me as I am working on the above feedback and wanted to get your take. |
Yes that works! That's how zapUndos works I believe. |
OK, I think we're ready for another review pass! |
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.
Still need to QA but no objections otherwise.
|
||
let sats = tipDefault || 1 | ||
let sats = calculatedDefault |
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.
Ohhh cool compatible with turbo zapping!
* add this day posting job * put in proper timezone * make sure we're in central timezone * schedule thisDay job
* Add WebLN for sending payments * attach docs for alby --------- Co-authored-by: Keyan <[email protected]> Co-authored-by: keyan <[email protected]>
* remove available prop * 'enabled' checkbox is now always enabled but uses validation * CheckboxGroup was missing to show error message
Description
Closes #1112
Adds an option to enable random zap amounts as a user setting.
Users can opt in to random zapping in their settings. If they enable the setting, they must pick a minimum and maximum random zap in their user settings before being able to save this option.
Random zaps take precedence over a default zap value.
Random zap config is validated to ensure that a min and max is specified, and that the min is less than the max, if the feature is enabled.
Screenshots
Additional Context
N/A
Checklist
Are your changes backwards compatible? Please answer below:
Yes
Did you QA this? Could we deploy this straight to production? Please answer below:
Yes
For frontend changes: Tested on mobile? Please answer below:
I made the desktop window smaller but that's about it.
Did you introduce any new environment variables? If so, call them out explicitly here:
No.