Changeset View
Standalone View
web/chat/chat-input-bar.react.js
Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | if (!isMember && canJoin && !this.props.threadCreationInProgress) { | ||||
{buttonContent} | {buttonContent} | ||||
</Button> | </Button> | ||||
</div> | </div> | ||||
); | ); | ||||
} | } | ||||
const { pendingUploads, cancelPendingUpload } = this.props.inputState; | const { pendingUploads, cancelPendingUpload } = this.props.inputState; | ||||
const multimediaPreviews = pendingUploads.map(pendingUpload => { | const multimediaPreviews = pendingUploads.map(pendingUpload => { | ||||
let mediaSource; | const { uri, mediaType, thumbHash, dimensions } = pendingUpload; | ||||
ashoat: I was surprised to see `thumbHash` always included for pending uploads, so I took a look at… | |||||
bartekAuthorUnsubmitted Done Inline Actions
That's correct, we set anything video-related to null in pending upload based sources.
Yes, we should! Good catch, that was my oversight that I didn't update that part initially. Created D7965 to address this, I also removed the non-applicable comment there. bartek: > I was surprised to see `thumbHash` always included for pending uploads, so I took a look at… | |||||
if ( | let mediaSource = { thumbHash, dimensions }; | ||||
pendingUpload.mediaType !== 'encrypted_photo' && | if (mediaType !== 'encrypted_photo' && mediaType !== 'encrypted_video') { | ||||
pendingUpload.mediaType !== 'encrypted_video' | |||||
) { | |||||
mediaSource = { | mediaSource = { | ||||
type: pendingUpload.mediaType, | ...mediaSource, | ||||
uri: pendingUpload.uri, | type: mediaType, | ||||
uri, | |||||
thumbnailURI: null, | |||||
}; | }; | ||||
} else { | } else { | ||||
const { encryptionKey } = pendingUpload; | |||||
invariant( | invariant( | ||||
pendingUpload.encryptionKey, | encryptionKey, | ||||
'encryptionKey should be set for encrypted media', | 'encryptionKey should be set for encrypted media', | ||||
); | ); | ||||
mediaSource = { | mediaSource = { | ||||
type: pendingUpload.mediaType, | ...mediaSource, | ||||
holder: pendingUpload.uri, | type: mediaType, | ||||
encryptionKey: pendingUpload.encryptionKey, | holder: uri, | ||||
encryptionKey, | |||||
thumbnailHolder: null, | |||||
thumbnailEncryptionKey: null, | |||||
}; | }; | ||||
} | } | ||||
return ( | return ( | ||||
<Multimedia | <Multimedia | ||||
mediaSource={mediaSource} | mediaSource={mediaSource} | ||||
pendingUpload={pendingUpload} | pendingUpload={pendingUpload} | ||||
remove={cancelPendingUpload} | remove={cancelPendingUpload} | ||||
multimediaCSSClass={css.multimedia} | multimediaCSSClass={css.multimedia} | ||||
▲ Show 20 Lines • Show All 397 Lines • Show Last 20 Lines |
I was surprised to see thumbHash always included for pending uploads, so I took a look at InputStateContainer on web. It does appear that we always attempt to generate a thumbHash in appendFile. Meanwhile, thumbnail stuff is not set because we don't yet support video uploads on web.
One question did come up in my reading. I was reading this code, which is called when a message is sent, and does the work of optimistically creating a RawMessageInfo with the media before we receive a respond from the keyserver.
In that code, it appears that we don't pass the thumbHash into the RawMessageInfo. I guess we probably skip it because the object URL can be rendered instantly, but I found myself wondering why we don't do the same thing for the multimedia previews here. Shouldn't we be consistent?
Separately, the comment in the linked code should probably be updated. In particular, the following no longer applies:
(We now use the dimensions on the web, precisely for rendering a properly size loading overlay.)