Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3553700
D10037.id33920.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D10037.id33920.diff
View Options
diff --git a/lib/actions/upload-actions.js b/lib/actions/upload-actions.js
--- a/lib/actions/upload-actions.js
+++ b/lib/actions/upload-actions.js
@@ -131,11 +131,16 @@
+loop?: boolean,
};
+export type BlobServiceUploadResult = {
+ ...UploadMultimediaResult,
+ blobHolder: ?string,
+};
+
export type BlobServiceUploadAction = (input: {
+uploadInput: BlobServiceUploadInput,
+keyserverOrThreadID: string,
+callbacks?: MultimediaUploadCallbacks,
-}) => Promise<{ ...UploadMultimediaResult, blobHolder: ?string }>;
+}) => Promise<BlobServiceUploadResult>;
const blobServiceUpload =
(callKeyserverEndpoint: CallKeyserverEndpoint): BlobServiceUploadAction =>
diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js
--- a/native/input/input-state-container.react.js
+++ b/native/input/input-state-container.react.js
@@ -26,6 +26,7 @@
type MultimediaUploadCallbacks,
type MultimediaUploadExtras,
type BlobServiceUploadAction,
+ type BlobServiceUploadResult,
} from 'lib/actions/upload-actions.js';
import commStaffCommunity from 'lib/facts/comm-staff-community.js';
import { pathFromURI, replaceExtension } from 'lib/media/file-utils.js';
@@ -839,47 +840,47 @@
uploadThumbnailResult,
mediaMissionResult;
try {
- const uploadPromises = [];
if (
this.useBlobServiceUploads &&
(processedMedia.mediaType === 'encrypted_photo' ||
processedMedia.mediaType === 'encrypted_video')
) {
- uploadPromises.push(
- this.props.blobServiceUpload({
- uploadInput: {
- blobInput: {
- type: 'uri',
- uri: uploadURI,
- filename: filename,
- mimeType: mime,
- },
- blobHash: processedMedia.blobHash,
- encryptionKey: processedMedia.encryptionKey,
- dimensions: processedMedia.dimensions,
- thumbHash:
- processedMedia.mediaType === 'encrypted_photo'
- ? processedMedia.thumbHash
- : null,
+ const uploadPromise = this.props.blobServiceUpload({
+ uploadInput: {
+ blobInput: {
+ type: 'uri',
+ uri: uploadURI,
+ filename: filename,
+ mimeType: mime,
},
- keyserverOrThreadID: threadInfo.id,
- callbacks: {
- blobServiceUploadHandler,
- onProgress: (percent: number) => {
- this.setProgress(
- localMessageID,
- localMediaID,
- 'uploading',
- percent,
- );
- },
+ blobHash: processedMedia.blobHash,
+ encryptionKey: processedMedia.encryptionKey,
+ dimensions: processedMedia.dimensions,
+ thumbHash:
+ processedMedia.mediaType === 'encrypted_photo'
+ ? processedMedia.thumbHash
+ : null,
+ },
+ keyserverOrThreadID: threadInfo.id,
+ callbacks: {
+ blobServiceUploadHandler,
+ onProgress: (percent: number) => {
+ this.setProgress(
+ localMessageID,
+ localMediaID,
+ 'uploading',
+ percent,
+ );
},
- }),
- );
+ },
+ });
- if (processedMedia.mediaType === 'encrypted_video') {
- uploadPromises.push(
- this.props.blobServiceUpload({
+ const uploadThumbnailPromise: Promise<?BlobServiceUploadResult> =
+ (async () => {
+ if (processedMedia.mediaType !== 'encrypted_video') {
+ return undefined;
+ }
+ return await this.props.blobServiceUpload({
uploadInput: {
blobInput: {
type: 'uri',
@@ -897,49 +898,51 @@
callbacks: {
blobServiceUploadHandler,
},
- }),
- );
- }
- [uploadResult, uploadThumbnailResult] = await Promise.all(
- uploadPromises,
- );
+ });
+ })();
+
+ [uploadResult, uploadThumbnailResult] = await Promise.all([
+ uploadPromise,
+ uploadThumbnailPromise,
+ ]);
} else {
- uploadPromises.push(
- this.props.uploadMultimedia(
- { uri: uploadURI, name: filename, type: mime },
- {
- ...processedMedia.dimensions,
- loop:
- processedMedia.mediaType === 'video' ||
- processedMedia.mediaType === 'encrypted_video'
- ? processedMedia.loop
- : undefined,
- encryptionKey: processedMedia.encryptionKey,
- thumbHash:
- processedMedia.mediaType === 'photo' ||
- processedMedia.mediaType === 'encrypted_photo'
- ? processedMedia.thumbHash
- : null,
- },
- {
- onProgress: (percent: number) =>
- this.setProgress(
- localMessageID,
- localMediaID,
- 'uploading',
- percent,
- ),
- uploadBlob: this.uploadBlob,
- },
- ),
+ const uploadPromise = this.props.uploadMultimedia(
+ { uri: uploadURI, name: filename, type: mime },
+ {
+ ...processedMedia.dimensions,
+ loop:
+ processedMedia.mediaType === 'video' ||
+ processedMedia.mediaType === 'encrypted_video'
+ ? processedMedia.loop
+ : undefined,
+ encryptionKey: processedMedia.encryptionKey,
+ thumbHash:
+ processedMedia.mediaType === 'photo' ||
+ processedMedia.mediaType === 'encrypted_photo'
+ ? processedMedia.thumbHash
+ : null,
+ },
+ {
+ onProgress: (percent: number) =>
+ this.setProgress(
+ localMessageID,
+ localMediaID,
+ 'uploading',
+ percent,
+ ),
+ uploadBlob: this.uploadBlob,
+ },
);
- if (
- processedMedia.mediaType === 'video' ||
- processedMedia.mediaType === 'encrypted_video'
- ) {
- uploadPromises.push(
- this.props.uploadMultimedia(
+ const uploadThumbnailPromise: Promise<?UploadMultimediaResult> =
+ (async () => {
+ if (
+ processedMedia.mediaType !== 'video' &&
+ processedMedia.mediaType !== 'encrypted_video'
+ ) {
+ return undefined;
+ }
+ return await this.props.uploadMultimedia(
{
uri: processedMedia.uploadThumbnailURI,
name: replaceExtension(`thumb${filename}`, 'jpg'),
@@ -954,12 +957,13 @@
{
uploadBlob: this.uploadBlob,
},
- ),
- );
- }
- [uploadResult, uploadThumbnailResult] = await Promise.all(
- uploadPromises,
- );
+ );
+ })();
+
+ [uploadResult, uploadThumbnailResult] = await Promise.all([
+ uploadPromise,
+ uploadThumbnailPromise,
+ ]);
}
mediaMissionResult = { success: true };
} catch (e) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 27, 8:57 PM (4 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2713031
Default Alt Text
D10037.id33920.diff (7 KB)
Attached To
Mode
D10037: [Flow202][native][skip-ci] [53/x] Address type errors with Promise.all in InputStateContainer
Attached
Detach File
Event Timeline
Log In to Comment