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

Lazy load ViewShot #5517

Merged
merged 5 commits into from
Sep 27, 2024
Merged

Lazy load ViewShot #5517

merged 5 commits into from
Sep 27, 2024

Conversation

haileyok
Copy link
Contributor

@haileyok haileyok commented Sep 27, 2024

Why

Now that we are able to, we should lazy-load ViewShot, since it saves us almost 80kb

How

Just using React.lazy and React.Suspense. Extremely basic for the QR code dialog, we just use React.Suspense to show the spinner until view-shot has loaded.

For signup, we won't actually use React.Suspense, because we don't want the user to get blocked from signing up for any reason. However, we will try to make sure it's ready to go by the time the user gets to that screen.

  • On "continue" from the account info screen (very first step of registration), we'll call import() for view-shot
  • By the time we get to the avatar creator, it should be loaded
  • If it isn't loaded though, it will just result in an undefined avatar URL and the user will just get the default avatar.

Test Plan

Go through an account creation, you should still get one of the "new" default avatars. Also verify that QR codes still work.

@arcalinea arcalinea temporarily deployed to hailey/lazy-view-shot - social-app PR #5517 September 27, 2024 02:49 — with Render Destroyed
Copy link

github-actions bot commented Sep 27, 2024

Old size New size Diff
9.97 MB 9.77 MB -203 KB (-1.99%)

@@ -33,12 +37,12 @@ export const PlaceholderCanvas = React.forwardRef<PlaceholderCanvasRef, {}>(

React.useImperativeHandle(ref, () => ({
// @ts-ignore this library doesn't have types
capture: viewshotRef.current.capture,
capture: viewshotRef.current?.capture,
Copy link
Collaborator

Choose a reason for hiding this comment

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

are we ok with this method being null in some cases? should we instead wrap to make it a noop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i tweaked it like this so it will show up as possibly being undefined 3b220f6 (#5517)

im going to see if i can just get rid of that ts-ignore though, i think there actually is a type for this

Copy link
Contributor Author

@haileyok haileyok Sep 27, 2024

Choose a reason for hiding this comment

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

okay yea, this feels nicer 1006d70 (#5517) (plus this to only import the type, oops 18462ad)

@arcalinea arcalinea temporarily deployed to hailey/lazy-view-shot - social-app PR #5517 September 27, 2024 03:05 — with Render Destroyed
@arcalinea arcalinea temporarily deployed to hailey/lazy-view-shot - social-app PR #5517 September 27, 2024 03:09 — with Render Destroyed
@haileyok haileyok force-pushed the hailey/lazy-view-shot branch from a14804d to 1006d70 Compare September 27, 2024 03:10
@arcalinea arcalinea temporarily deployed to hailey/lazy-view-shot - social-app PR #5517 September 27, 2024 03:10 — with Render Destroyed
@arcalinea arcalinea temporarily deployed to hailey/lazy-view-shot - social-app PR #5517 September 27, 2024 03:10 — with Render Destroyed
@gaearon gaearon merged commit 389e6f1 into main Sep 27, 2024
6 checks passed
@gaearon gaearon deleted the hailey/lazy-view-shot branch September 27, 2024 03:52
estrattonbailey added a commit that referenced this pull request Sep 30, 2024
* origin/main:
  Use Inter variable font (#5540)
  Fix name in `feature_request.yml` (#5542)
  Fix sticky offset, gear color (#5537)
  Move email test to root tests dir (#5527)
  revamp issue templates, add new arch template (#5532)
  use PressableScale for animation (#5541)
  Rework native autocomplete (#5521)
  Pinned posts (#5055)
  Remove Segment (#5518)
  Fix alignment of cancel button on search (#5520)
  [Share Extension] Support on Android for sharing videos to app (#5466)
  Ignore bogus onScroll values (#5499)
  add podcasts to spotify embeds (#5514)
  Tweak font size of "Write your reply" (#5513)
  Lazy load ViewShot (#5517)
  [Share Extension] Support images/movies from other apps like iMessage (#5515)
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