-
Notifications
You must be signed in to change notification settings - Fork 244
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
fix: gift subscription feedback #4160
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
export const ConditionalRender = ({ | ||
condition, | ||
children, | ||
}: Pick<ConditionalWrapperProps, 'condition' | 'children'>): ReactNode => { | ||
if (!condition) { | ||
return null; | ||
} | ||
|
||
return children; | ||
}; |
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 wanted to avoid the ugly ternary ladder, which adds indent and confusing conditions.
For example:
{!preselected ?
(selected ? (
<Component1 />
) : (
<Component2 />
)
)
: null
}
Instead, we can just do something similar to our ConditionalWrapper
by doing:
<ConditionalRender condition={isTrue}>
{
selected ? (
<Component1 />
) : (
<Component2 />
)
}
</ConditionalRender>
This will keep the ternaries to a single level.
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.
It doesn't really though right, it's just masking it.
Technically still read it as if...else inside if...else
Not against it, but not sure it's that much clearer.
@capJavert // @omBratteng what you guys think?
I'm happy to keep it though to unblock you.
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.
Personally, I just hate excessive indents and multiple ternaries at once, especially when combined together, as it would require you to focus deeply just to understand the simple if-else-if conditions. Also a simple misplacement of the parenthesis, the result would be totally different. Hence hard to follow.
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 more of a cosmetic than functional change for readability.
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.
Ah agreed I'd love to avoid the nested ternaries in the first place.
But to me this is just a wrapper the result is still having the ternary.
One other solution is to render 2 functions and do the inside ternary inside 1 function?
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.
Yeah, that can work too, by doing early returns. I'll be merging this now but I'll update and raise another PR once we get more answers on what could fit our current setup.
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.
Looks good code wise ✅
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.
One non blocking comment.
export const ConditionalRender = ({ | ||
condition, | ||
children, | ||
}: Pick<ConditionalWrapperProps, 'condition' | 'children'>): ReactNode => { | ||
if (!condition) { | ||
return null; | ||
} | ||
|
||
return children; | ||
}; |
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.
It doesn't really though right, it's just masking it.
Technically still read it as if...else inside if...else
Not against it, but not sure it's that much clearer.
@capJavert // @omBratteng what you guys think?
I'm happy to keep it though to unblock you.
@@ -89,7 +88,7 @@ export default function CommentActionButtons({ | |||
const { onMenuClick, isOpen, onHide } = useContextMenu({ id }); | |||
const { openModal } = useLazyModal(); | |||
const { displayToast } = useToastNotification(); | |||
const { isPlusAvailable } = usePaymentContext(); | |||
const { isValidRegion: isPlusAvailable } = useAuthContext(); |
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.
Oh I see we actually already just re-export it lol.
Yeah this is better.
* feat: gift user modal (#4091) * feat: add gift option to profile menu (#4085) * feat: Add gift option to profile menu * feat: gift user modal * add the modal * feat: search user with mention * tmp: show modal * fix: on change handler * fix: debounce * fix: keyboard navigation * fix: arrow and on focus * feat: on hover, set selected * fix: ref * fix: index * fix: overlay append * fix: interactivity * fix: on close * fix: selected ui * fix: gap * fix: alignment * fix: roundness * fix: TODO * fix: checking disabled * Revert "tmp: show modal" This reverts commit 3f53473. * fix: missing context provider * fix: modal pricing * fix: missing preselected user --------- Co-authored-by: Lee Hansel Solevilla <sshanzel@yahoo.com> Co-authored-by: Lee Hansel Solevilla <13744167+sshanzel@users.noreply.github.com> * feat: gift plus in invite friends section (#4097) * feat: Add gift option to profile menu * feat: gift user modal * add the modal * feat: search user with mention * tmp: show modal * fix: on change handler * fix: debounce * fix: keyboard navigation * fix: arrow and on focus * feat: on hover, set selected * fix: ref * fix: index * fix: overlay append * fix: interactivity * fix: on close * fix: selected ui * fix: gap * fix: alignment * fix: roundness * fix: TODO * fix: checking disabled * Revert "tmp: show modal" This reverts commit 3f53473. * fix: missing context provider * fix: modal pricing * fix: missing preselected user * feat: gift plus in invite friends section --------- Co-authored-by: Lee Hansel Solevilla <sshanzel@yahoo.com> Co-authored-by: Lee Hansel Solevilla <13744167+sshanzel@users.noreply.github.com> * feat: add gift button to dropdowns (#4092) * feat: Add gift option to profile menu * feat: gift user modal * add the modal * feat: Add gift butto to dropdowns * feat: search user with mention * tmp: show modal * fix: on change handler * fix: debounce * fix: keyboard navigation * fix: arrow and on focus * feat: on hover, set selected * fix: ref * fix: index * fix: overlay append * fix: interactivity * fix: on close * fix: selected ui * fix: gap * fix: alignment * fix: roundness * fix: TODO * fix: checking disabled * Revert "tmp: show modal" This reverts commit 3f53473. * fix: missing context provider * fix: modal pricing * fix: missing preselected user * chore: update blocker --------- Co-authored-by: Lee Hansel Solevilla <sshanzel@yahoo.com> Co-authored-by: Lee Hansel Solevilla <13744167+sshanzel@users.noreply.github.com> * refactor: plus page to allow gifting another user (#4108) * fix: usage of apps id from paddle (#4123) * fix: gifting while user is a Plus member already (#4131) * feat: notification modal opening logic (#4132) * feat: gift tracking (#4135) * feat: add missing gifter_id param in checkout (#4137) * fix: merge issues * fix: missing gifter id * fix: is disabled * refactor: unnecessary const * revert: privacy to all * fix: gift subscription feedback (#4160) * fix: displayed ui when gifted (#4169) * fix: typo --------- Co-authored-by: Lee Hansel Solevilla <13744167+sshanzel@users.noreply.github.com> Co-authored-by: Amar Trebinjac <36768584+AmarTrebinjac@users.noreply.github.com> Co-authored-by: Lee Hansel Solevilla <sshanzel@yahoo.com>
Changes
Preview:
Events
Did you introduce any new tracking events?
Experiment
Did you introduce any new experiments?
Manual Testing
Caution
Please make sure existing components are not breaking/affected by this PR
Preview domain
https://fix-gift-feedback.preview.app.daily.dev