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

Reduce lag when toggling sets #1837

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Conversation

eeeqeee
Copy link
Collaborator

@eeeqeee eeeqeee commented Mar 26, 2024

Describe your changes

Updating set effects is still delayed (e.g toggle Bloodstained Chivalry); this was previously hidden by the lag

Issue or discord link

Fix #1823

Testing/validation

Checklist before requesting a review (leave this PR as draft if any part of this list is not done.)

  • I have commented my code in hard-to understand areas.
  • I have made corresponding changes to README or wiki.
  • For front-end changes, I have updated the corresponding English translations.
  • I have run yarn run mini-ci locally to validate format and lint.
  • If I have added a new library or app, I have updated the deployment scripts to ignore changes as needed

Copy link
Contributor

github-actions bot commented Mar 26, 2024

[frontend] [Tue Mar 26 18:15:58 UTC 2024] - Deployed 929aa5a to https://genshin-optimizer-prs.github.io/pr/1837/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Tue Mar 26 18:21:47 UTC 2024] - Deployed 249ed9d to https://genshin-optimizer-prs.github.io/pr/1837/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Wed Mar 27 02:55:17 UTC 2024] - Deployed 8c031ba to https://genshin-optimizer-prs.github.io/pr/1837/frontend (Takes 3-5 minutes after this completes to be available)

[frontend] [Wed Apr 3 01:59:06 UTC 2024] - Deployed f115bc8 to https://genshin-optimizer-prs.github.io/pr/1837/frontend (Takes 3-5 minutes after this completes to be available)

* React compares objects by pointer equality, so `[...new Set(xs)].filter(f)`
* always causes a rerender
*/
function uniqueFilterInplace<T>(xs: T[], f: (x: T) => boolean): T[] {
Copy link
Owner

Choose a reason for hiding this comment

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

I think it may make sense to use React.memo's arePropsEqual to do a JSON string comparison on the UI update side, instead of "conserving references" in database (which kind of complicates the db logic).

<SqBadge color="info">
<AtkIcon {...iconInlineProps} /> {mainStatSlotTots.plume.atk}
</SqBadge>
return useMemo(
Copy link
Owner

@frzyc frzyc Mar 27, 2024

Choose a reason for hiding this comment

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

I think the way to go is to convert this into a React.memo function, and propdrill in mainStatKeys, and use arePropsEqual(compare JSON string) to check for update.

@frzyc
Copy link
Owner

frzyc commented Apr 15, 2024

Looks like this change has became too stale. I do support the changes you are making, but it seems that the underlying code has shifted too much.

@frzyc frzyc marked this pull request as draft April 15, 2024 00:03
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.

Toggling sets is laggy
2 participants