Page MenuHomePhabricator

[native] Extract LoadableImage component
ClosedPublic

Authored by bartek on Mar 29 2023, 6:40 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 6, 7:12 PM
Unknown Object (File)
Mon, Nov 4, 3:30 AM
Unknown Object (File)
Mon, Nov 4, 3:30 AM
Unknown Object (File)
Mon, Nov 4, 3:30 AM
Unknown Object (File)
Mon, Nov 4, 3:29 AM
Unknown Object (File)
Mon, Nov 4, 3:29 AM
Unknown Object (File)
Mon, Nov 4, 3:29 AM
Unknown Object (File)
Sun, Oct 27, 1:42 AM
Subscribers

Details

Summary

Addressing feedback from https://phab.comm.dev/D7225 - extracted the common part from <RemoteImage> to a new component: <LoadableImage>

Test Plan

Media images are still loaded and displayed correctly.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Mar 29 2023, 7:12 AM

Just a question. Will leave it on others' queue in case they have review comments

native/media/remote-image.react.js
33–41 ↗(On Diff #24328)

Given that both RemoteImage and RemoteImage seem to need this functionality, I'm wondering why you didn't factor it out into LoadableImage

atul added inline comments.
native/media/loadable-image.react.js
36 ↗(On Diff #24328)

Can we use React.useMemo here now that we're in a functional component?

This revision is now accepted and ready to land.Mar 29 2023, 12:01 PM
native/media/loadable-image.react.js
36 ↗(On Diff #24328)

Sure, I'll do it

native/media/remote-image.react.js
33–41 ↗(On Diff #24328)

I tried that at first, but it turned out to complicate code more. EncryptedImage needs the reconnection logic also in the hook, so we'd end up with duplicated connection-status logic anyway.

native/media/remote-image.react.js
33–41 ↗(On Diff #24328)

Ah, I see... LoadableImage can't handle attempt because the component that renders it, EncryptedImage, also needs awareness of attempt so that decryptMedia gets called again. That makes sense

Rebase before landing. Added useMemo for styles.

Removed unnecessary state (noticed that sometimes re-renders caused flickering)

This revision was automatically updated to reflect the committed changes.