OdyseeTeam / odysee-frontend

The code that runs odysee.com
https://odysee.com
MIT License
215 stars 68 forks source link

Mobile: Bad lag/slowness when entering repost name #3055

Open keikari opened 9 months ago

keikari commented 9 months ago

https://discord.com/channels/721806979928162404/1203405569000611890/1203405569000611890 "I went to repost something on iOS Safari and for some reason the typing speed in the URL text box tanked. It's running like shit. Discord's letting my type at full speed while that's in the background, and come to think of it, every part of the site needs to reload every time I switch apps."

Wasn't able to repro here, seeing some minor hiccups on Firefox android. But barely noticeable.

infinite-persistence commented 9 months ago

This code being placed too high up in the tree. RepostCreate that's underneath it is too huge to be re-rendering often.

  const throttledContentValue = useThrottle(contentUri, 500);
  const throttledRepostValue = useThrottle(repostUri, 500);

  React.useEffect(() => {
    if (throttledContentValue) {
      resolveUri(throttledContentValue);
    }
  }, [throttledContentValue, resolveUri]);

  React.useEffect(() => {
    if (throttledRepostValue) {
      resolveUri(throttledRepostValue);
    }
  }, [throttledRepostValue, resolveUri]);

  React.useEffect(() => {
    if (repostTo) {
      resolveUri(repostTo);
    }
  }, [repostTo, resolveUri]);

Suggestion:

Create a RepostName component that encapsulate the repost_name form field + other surrounding text elements + move the resolve calls here, so that the entire tree is not affected. If still not performant enough, exclude the check-as-you-type and just resolve in handleSubmit -- probably not too bad.

tzarebczan commented 8 months ago

Another related issue in this area - if there's alot of channel tags, they overlay the name input box and you can't click into it (it then goes to the URL you're reposting)

image