Changeset View
Changeset View
Standalone View
Standalone View
web/input/input-state-container.react.js
Show First 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | componentDidUpdate(prevProps: Props, prevState: State) { | ||||
} | } | ||||
const newMessageInfos = new Map(); | const newMessageInfos = new Map(); | ||||
for (const [messageID, assignedUploads] of newlyAssignedUploads) { | for (const [messageID, assignedUploads] of newlyAssignedUploads) { | ||||
const { uploads, threadID } = assignedUploads; | const { uploads, threadID } = assignedUploads; | ||||
const creatorID = this.props.viewerID; | const creatorID = this.props.viewerID; | ||||
invariant(creatorID, 'need viewer ID in order to send a message'); | invariant(creatorID, 'need viewer ID in order to send a message'); | ||||
const media = uploads.map( | const media = uploads.map( | ||||
({ localID, serverID, uri, mediaType, dimensions, encryptionKey }) => { | ({ | ||||
localID, | |||||
serverID, | |||||
uri, | |||||
mediaType, | |||||
dimensions, | |||||
encryptionKey, | |||||
thumbHash, | |||||
}) => { | |||||
// We can get into this state where dimensions are null if the user is | // We can get into this state where dimensions are null if the user is | ||||
// uploading a file type that the browser can't render. In that case | // uploading a file type that the browser can't render. In that case | ||||
// we fake the dimensions here while we wait for the server to tell us | // we fake the dimensions here while we wait for the server to tell us | ||||
// the true dimensions. We actually don't use the dimensions on the | // the true dimensions. | ||||
// web side currently, but if we ever change that (for instance if we | |||||
// want to render a properly sized loading overlay like we do on | |||||
// native), 0,0 is probably a good default. | |||||
const shimmedDimensions = dimensions ?? { height: 0, width: 0 }; | const shimmedDimensions = dimensions ?? { height: 0, width: 0 }; | ||||
invariant( | invariant( | ||||
mediaType === 'photo' || mediaType === 'encrypted_photo', | mediaType === 'photo' || mediaType === 'encrypted_photo', | ||||
"web InputStateContainer can't handle video", | "web InputStateContainer can't handle video", | ||||
); | ); | ||||
if ( | if ( | ||||
mediaType !== 'encrypted_photo' && | mediaType !== 'encrypted_photo' && | ||||
mediaType !== 'encrypted_video' | mediaType !== 'encrypted_video' | ||||
) { | ) { | ||||
return { | return { | ||||
id: serverID ? serverID : localID, | id: serverID ? serverID : localID, | ||||
uri, | uri, | ||||
type: 'photo', | type: 'photo', | ||||
dimensions: shimmedDimensions, | dimensions: shimmedDimensions, | ||||
thumbHash: null, | thumbHash, | ||||
}; | }; | ||||
} | } | ||||
invariant( | invariant( | ||||
encryptionKey, | encryptionKey, | ||||
'encrypted media must have an encryption key', | 'encrypted media must have an encryption key', | ||||
); | ); | ||||
return { | return { | ||||
id: serverID ? serverID : localID, | id: serverID ? serverID : localID, | ||||
holder: uri, | holder: uri, | ||||
type: 'encrypted_photo', | type: 'encrypted_photo', | ||||
encryptionKey, | encryptionKey, | ||||
dimensions: shimmedDimensions, | dimensions: shimmedDimensions, | ||||
thumbHash: null, | thumbHash, | ||||
}; | }; | ||||
}, | }, | ||||
); | ); | ||||
const messageInfo = createMediaMessageInfo( | const messageInfo = createMediaMessageInfo( | ||||
{ | { | ||||
localID: messageID, | localID: messageID, | ||||
threadID, | threadID, | ||||
creatorID, | creatorID, | ||||
▲ Show 20 Lines • Show All 1,416 Lines • Show Last 20 Lines |