Page MenuHomePhabricator

[native] Extract LoadableImage component
ClosedPublic

Authored by bartek on Mar 29 2023, 6:40 AM.
Tags
None
Referenced Files
F1708283: D7232.diff
Mon, May 6, 6:55 AM
Unknown Object (File)
Sun, May 5, 5:57 AM
Unknown Object (File)
Sat, May 4, 2:16 AM
Unknown Object (File)
Thu, May 2, 11:20 PM
Unknown Object (File)
Sat, Apr 27, 10:29 PM
Unknown Object (File)
Sat, Apr 27, 10:29 PM
Unknown Object (File)
Sat, Apr 27, 10:29 PM
Unknown Object (File)
Sat, Apr 27, 10:29 PM
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
No Lint Coverage
Unit
No Test Coverage

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

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

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

Sure, I'll do it

native/media/remote-image.react.js
33–41

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

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.