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

fix: gift subscription feedback #4160

Merged
merged 9 commits into from
Feb 7, 2025
Merged

Conversation

sshanzel
Copy link
Member

@sshanzel sshanzel commented Feb 6, 2025

Changes

  • App crashes on certain pages (due to some context not available on render).
  • Spacings on the Gifting option UI.
  • Fixed the profile UI for preselected user on the modal and when selecting a new one.

Preview:

Screenshot 2025-02-07 at 5 42 58 PM

Screenshot 2025-02-07 at 5 43 13 PM

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

Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
daily-webapp ✅ Ready (Inspect) Visit Preview Feb 7, 2025 3:13pm
1 Skipped Deployment
Name Status Preview Updated (UTC)
storybook ⬜️ Ignored (Inspect) Feb 7, 2025 3:13pm

Comment on lines +17 to +26
export const ConditionalRender = ({
condition,
children,
}: Pick<ConditionalWrapperProps, 'condition' | 'children'>): ReactNode => {
if (!condition) {
return null;
}

return children;
};
Copy link
Member Author

@sshanzel sshanzel Feb 6, 2025

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.

Copy link
Contributor

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.

Copy link
Member Author

@sshanzel sshanzel Feb 7, 2025

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.

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@ilasw ilasw left a 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 ✅

Copy link
Contributor

@rebelchris rebelchris left a 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.

Comment on lines +17 to +26
export const ConditionalRender = ({
condition,
children,
}: Pick<ConditionalWrapperProps, 'condition' | 'children'>): ReactNode => {
if (!condition) {
return null;
}

return children;
};
Copy link
Contributor

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();
Copy link
Contributor

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.

@sshanzel sshanzel merged commit 2ccdc43 into MI-746-gifting-plus Feb 7, 2025
10 checks passed
@sshanzel sshanzel deleted the fix-gift-feedback branch February 7, 2025 15:50
ilasw added a commit that referenced this pull request Feb 11, 2025
* 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>
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.

3 participants