From 5bdba4935a2ee5cfd5ab185413330d2c58ed6306 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Tue, 12 Nov 2019 04:51:32 -0800 Subject: [PATCH] Commit hash field added Summary: This diff adds commit hash field in the support form v2 and we prefill the information. If changes are not pushed to phabricator we will populate it with commit hash or else we will populate it with Diff number. See the demo to understand the flow. {F222000517} Reviewed By: jknoxville Differential Revision: D18427044 fbshipit-source-id: 80a58baca381e21203da5670e29144a7e8c2eeed --- src/utils/promiseTimeout.tsx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/utils/promiseTimeout.tsx b/src/utils/promiseTimeout.tsx index bfceeb780..21c1dea03 100644 --- a/src/utils/promiseTimeout.tsx +++ b/src/utils/promiseTimeout.tsx @@ -7,6 +7,8 @@ * @format */ +import {StatusMessageType} from '../reducers/application'; + export default function promiseTimeout( ms: number, promise: Promise, @@ -23,3 +25,23 @@ export default function promiseTimeout( // Returns a race between our timeout and the passed in promise return Promise.race([promise, timeout]); } + +export function showStatusUpdatesForPromise( + promise: Promise, + message: string, + sender: string, + addStatusMessage: (payload: StatusMessageType) => void, + removeStatusMessage: (payload: StatusMessageType) => void, +): Promise { + const statusMsg = {msg: message, sender}; + addStatusMessage(statusMsg); + return promise + .then(result => { + removeStatusMessage(statusMsg); + return result; + }) + .catch(e => { + removeStatusMessage(statusMsg); + throw e; + }); +}