From e37d5991cfe161fe8b06ce46d4b010c781d4d58a Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Wed, 8 Jun 2022 21:36:18 +0200 Subject: [PATCH] Refine photo upload messaging --- src/screens/Compose/Root/Footer/addAttachment.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/screens/Compose/Root/Footer/addAttachment.ts b/src/screens/Compose/Root/Footer/addAttachment.ts index 5b692c9b..268efa3c 100644 --- a/src/screens/Compose/Root/Footer/addAttachment.ts +++ b/src/screens/Compose/Root/Footer/addAttachment.ts @@ -82,7 +82,7 @@ export const uploadAttachment = async ({ break } - const uploadFailed = () => { + const uploadFailed = (message?: string) => { composeDispatch({ type: 'attachment/upload/fail', payload: hash @@ -91,7 +91,7 @@ export const uploadAttachment = async ({ i18next.t( 'screenCompose:content.root.actions.attachment.failed.alert.title' ), - undefined, + message, [ { text: i18next.t( @@ -126,8 +126,12 @@ export const uploadAttachment = async ({ uploadFailed() } }) - .catch(() => { - uploadFailed() + .catch((err: any) => { + uploadFailed( + err?.message && typeof err?.message === 'string' + ? err?.message.slice(0, 50) + : undefined + ) }) } @@ -141,6 +145,7 @@ const chooseAndUploadAttachment = async ({ }) for (const media of result) { uploadAttachment({ composeDispatch, media }) + await new Promise(res => setTimeout(res, 500)) } }