Skip to content

fix: Avoid resetting state one every render.#10210

Merged
hariombalhara merged 2 commits intomainfrom
state-reset-fix
Jul 18, 2023
Merged

fix: Avoid resetting state one every render.#10210
hariombalhara merged 2 commits intomainfrom
state-reset-fix

Conversation

@hariombalhara
Copy link
Copy Markdown
Member

What does this PR do?

Fixes #10087
Removes usage of withQuery(which is deprecated). withQuery returns new function instance on each call which causes the component to lose it's state on every render.

Before: https://user-images.githubusercontent.com/72548403/252946101-bc1b985a-eced-4d3f-b354-e3ac96ac7bb8.gif

After fix demo

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How should this be tested?

  • See the loom

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

  • I haven't added tests that prove my fix is effective or that my feature works

@hariombalhara hariombalhara added the 📉 regressing This used to work. Now it doesn't anymore. label Jul 18, 2023
@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 18, 2023

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

Name Status Preview Comments Updated (UTC)
api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2023 4:37pm
cal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2023 4:37pm
cal-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2023 4:37pm
cal-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2023 4:37pm
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2023 4:37pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
qa ⬜️ Ignored (Inspect) Jul 18, 2023 4:37pm

@github-actions github-actions Bot added embed area: embed, widget, react embed Medium priority Created by Linear-GitHub Sync 🐛 bug Something isn't working labels Jul 18, 2023
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 18, 2023

Thank you for following the naming conventions! 🙏

@alwaysmeticulous
Copy link
Copy Markdown

alwaysmeticulous Bot commented Jul 18, 2023

🤖 Meticulous spotted visual differences in 50 of 189 screens tested: view and approve differences detected.

Last updated for commit 88a0dea. This comment will update as new commits are pushed.

@zomars zomars added the core area: core, team members only label Jul 18, 2023
Comment on lines -885 to -929
const isFilteredByOnlyOneItem =
(filters?.teamIds?.length === 1 || filters?.userIds?.length === 1) &&
data.eventTypeGroups.length === 1;

return (
<>
{data.eventTypeGroups.length > 1 || isFilteredByOnlyOneItem ? (
<>
{isMobile ? (
<MobileTeamsTab eventTypeGroups={data.eventTypeGroups} />
) : (
data.eventTypeGroups.map((group: EventTypeGroup, index: number) => (
<div className="flex flex-col" key={group.profile.slug}>
<EventTypeListHeading
profile={group.profile}
membershipCount={group.metadata.membershipCount}
teamId={group.teamId}
orgSlug={orgBranding?.slug}
/>

<EventTypeList
types={group.eventTypes}
group={group}
groupIndex={index}
readOnly={group.metadata.readOnly}
/>
</div>
))
)}
</>
) : (
data.eventTypeGroups.length === 1 && (
<EventTypeList
types={data.eventTypeGroups[0].eventTypes}
group={data.eventTypeGroups[0]}
groupIndex={0}
readOnly={data.eventTypeGroups[0].metadata.readOnly}
/>
)
)}

{data.eventTypeGroups.length === 0 && <CreateFirstEventTypeView />}

<EmbedDialog />
{router.query.dialog === "duplicate" && <DuplicateDialog />}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Moved this to Main component

@hariombalhara hariombalhara requested review from a team July 18, 2023 07:20
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 18, 2023

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@deploysentinel
Copy link
Copy Markdown

deploysentinel Bot commented Jul 18, 2023

Current Playwright Test Results Summary

✅ 94 Passing - ⚠️ 4 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 07/18/2023 04:41:52pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: 88a0dea

Started: 07/18/2023 04:38:39pm UTC

⚠️ Flakes

📄   apps/web/playwright/login.2fa.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
2FA Tests should allow a user to enable 2FA and login using 2FA
Retry 2Retry 1Initial Attempt
14.46% (48) 48 / 332 runs
failed over last 7 days
20.18% (67) 67 / 332 runs
flaked over last 7 days
2FA Tests should allow a user to disable 2FA
Retry 1Initial Attempt
0% (0) 0 / 333 runs
failed over last 7 days
4.50% (15) 15 / 333 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/action-based.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Popup Tests should be able to reschedule
Retry 2Retry 1Initial Attempt
1.26% (2) 2 / 159 runs
failed over last 7 days
98.11% (156) 156 / 159 runs
flaked over last 7 days

📄   apps/web/playwright/webhook.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
BOOKING_REJECTED can book an event that requires confirmation and then that booking can be rejected by organizer
Retry 1Initial Attempt
0.58% (2) 2 / 344 runs
failed over last 7 days
5.23% (18) 18 / 344 runs
flaked over last 7 days

View Detailed Build Results


Copy link
Copy Markdown
Member

@sean-brydon sean-brydon left a comment

Choose a reason for hiding this comment

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

Nice! This was on my todos actually cause i hate withquery :P

Tested and it seems to work fine for me! I think in the future we should spit up loading eventTypes for users and times so we can do them in separate queries. (Not related to this PR at all :P )

@hariombalhara hariombalhara enabled auto-merge (squash) July 18, 2023 16:30
Copy link
Copy Markdown
Contributor

@shivamklr shivamklr left a comment

Choose a reason for hiding this comment

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

Tested locally, works great.

fritterhoff pushed a commit to hm-edu/cal.com that referenced this pull request Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working core area: core, team members only embed area: embed, widget, react embed Medium priority Created by Linear-GitHub Sync 📉 regressing This used to work. Now it doesn't anymore.

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

Preview State in Embed Dialog is getting revert to default state after changing the tabs

4 participants