Page MenuHomePhabricator

D9711.diff
No OneTemporary

D9711.diff

diff --git a/lib/utils/action-utils.js b/lib/utils/action-utils.js
--- a/lib/utils/action-utils.js
+++ b/lib/utils/action-utils.js
@@ -282,7 +282,7 @@
) => {
const startingPayload = { ...inputStartingPayload, logInActionSource };
dispatch(wrapActionPromise(actionTypes, promise, null, startingPayload));
- return new Promise(r => (callServerEndpointCallback = r));
+ return new Promise<boolean>(r => (callServerEndpointCallback = r));
};
await resolveInvalidatedCookie(
boundCallServerEndpoint,
@@ -340,7 +340,9 @@
return Promise.resolve(null);
}
// Wait to run until we get our new cookie
- return new Promise(r => serverEndpointCallsWaitingForNewCookie.push(r));
+ return new Promise<?CallServerEndpoint>(r =>
+ serverEndpointCallsWaitingForNewCookie.push(r),
+ );
};
// This function is a helper for the next function defined below
const attemptToResolveInvalidation = async (
@@ -387,7 +389,9 @@
return Promise.resolve(null);
}
if (currentlyWaitingForNewCookie) {
- return new Promise(r => serverEndpointCallsWaitingForNewCookie.push(r));
+ return new Promise<?CallServerEndpoint>(r =>
+ serverEndpointCallsWaitingForNewCookie.push(r),
+ );
}
currentlyWaitingForNewCookie = true;
return attemptToResolveInvalidation(sessionChange);
diff --git a/lib/utils/blob-service-upload.js b/lib/utils/blob-service-upload.js
--- a/lib/utils/blob-service-upload.js
+++ b/lib/utils/blob-service-upload.js
@@ -42,7 +42,7 @@
}
let failed = false;
- const responsePromise = new Promise((resolve, reject) => {
+ const responsePromise = new Promise<void>((resolve, reject) => {
xhr.onload = () => {
if (failed) {
return;
diff --git a/lib/utils/upload-blob.js b/lib/utils/upload-blob.js
--- a/lib/utils/upload-blob.js
+++ b/lib/utils/upload-blob.js
@@ -66,41 +66,43 @@
}
let failed = false;
- const responsePromise = new Promise((resolve, reject) => {
- xhr.onload = () => {
- if (failed) {
- return;
- }
- const text = xhr.responseText;
- try {
- resolve(JSON.parse(text));
- } catch (e) {
- console.log(text);
- reject(e);
- }
- };
- xhr.onabort = () => {
- failed = true;
- reject(new Error('request aborted'));
- };
- xhr.onerror = event => {
- failed = true;
- reject(event);
- };
- if (options && options.timeout) {
- xhr.ontimeout = event => {
- failed = true;
- reject(event);
+ const responsePromise = new Promise<CallServerEndpointResponse>(
+ (resolve, reject) => {
+ xhr.onload = () => {
+ if (failed) {
+ return;
+ }
+ const text = xhr.responseText;
+ try {
+ resolve(JSON.parse(text));
+ } catch (e) {
+ console.log(text);
+ reject(e);
+ }
};
- }
- if (options && options.abortHandler) {
- options.abortHandler(() => {
+ xhr.onabort = () => {
failed = true;
reject(new Error('request aborted'));
- xhr.abort();
- });
- }
- });
+ };
+ xhr.onerror = event => {
+ failed = true;
+ reject(event);
+ };
+ if (options && options.timeout) {
+ xhr.ontimeout = event => {
+ failed = true;
+ reject(event);
+ };
+ }
+ if (options && options.abortHandler) {
+ options.abortHandler(() => {
+ failed = true;
+ reject(new Error('request aborted'));
+ xhr.abort();
+ });
+ }
+ },
+ );
if (!failed) {
xhr.send(formData);

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 8:42 PM (1 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2703121
Default Alt Text
D9711.diff (3 KB)

Event Timeline