-
Notifications
You must be signed in to change notification settings - Fork 5
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
Use Suspense for Image loading to reduce the cognitive overload in the code and also utilize the react18 concurrent rendering #632
base: main
Are you sure you want to change the base?
Conversation
|
03ac11f
to
00f0450
Compare
const [imageUri, setImageUri] = useState<undefined | string>(); | ||
const { data: imageUri } = useSWR( | ||
{ widgetApi, baseUrl, mxc, mimeType }, | ||
downloadFile, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cant call downloadFile directly as we want values from props. It would rerender contantly. SWR glues this (and also gives us caching)
downloadFile(); | ||
}, [baseUrl, mimeType, mxc, widgetApi]); | ||
|
||
const renderedSkeleton = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The errors and skeleton are now handled one component above with error handling and suspense
…e code and also utilize the react18 concurrent rendering Signed-off-by: MTRNord <[email protected]> Fix formatting Signed-off-by: MTRNord <[email protected]>
… suspense nesting Signed-off-by: MTRNord <[email protected]>
…ve a revalidation required in this case Signed-off-by: MTRNord <[email protected]>
Signed-off-by: MTRNord <[email protected]>
82e08ff
to
3db8ff3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally did a proper review. See my comments.
While caching improves when you navigate the slides (images do not show a loader any more) there is now another weird behaviour:
- Upload an image
- Keep the slide with the image open
- Switch to another window (I did switch the workspace) for some minutes (not sure when exactly this happens)
- Go back to the board
- Image shows the loader and flickers for a short time
Tested in Firefox 132.0.2
packages/react-sdk/src/components/elements/image/ImageDisplay.tsx
Outdated
Show resolved
Hide resolved
packages/react-sdk/src/components/elements/image/ImageDisplay.tsx
Outdated
Show resolved
Hide resolved
packages/react-sdk/src/components/elements/image/ImageDisplay.tsx
Outdated
Show resolved
Hide resolved
packages/react-sdk/src/components/elements/image/ImageDisplay.tsx
Outdated
Show resolved
Hide resolved
packages/react-sdk/src/components/elements/image/ImageDisplay.tsx
Outdated
Show resolved
Hide resolved
packages/react-sdk/src/components/Whiteboard/Element/ConnectedElement.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: MTRNord <[email protected]>
Signed-off-by: MTRNord <[email protected]>
…stead cache the blob itself and then load it as a blob Signed-off-by: MTRNord <[email protected]>
Signed-off-by: MTRNord <[email protected]>
Related: NEO-1033
This makes use of a few new things:
This is very much an experiment and probably not perfect yet. However on my pc it feels like loading got snappier on image heavy boards like those with imported PDFs.
✔️ Checklist
Signed-off-by
line in the message (more info).