From 8caf31589472575f915f58311fb97a9bd34d8812 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Thu, 5 May 2022 23:08:29 +0200 Subject: [PATCH] Improve sharing error messaging --- src/Screens.tsx | 28 ++++++++++++++++++++++++++++ src/components/Message.tsx | 2 +- src/i18n/en/screens.json | 4 ++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Screens.tsx b/src/Screens.tsx index 8420c867..6fa2fa60 100644 --- a/src/Screens.tsx +++ b/src/Screens.tsx @@ -197,6 +197,13 @@ const Screens: React.FC = ({ localCorrupt }) => { 'Image type not supported:', mimeType.split('/')[1] ) + displayMessage({ + message: t('shareError.imageNotSupported', { + type: mimeType.split('/')[1] + }), + type: 'error', + theme + }) return } images.push({ type: mimeType.split('/')[1], uri: data }) @@ -206,6 +213,13 @@ const Screens: React.FC = ({ localCorrupt }) => { 'Video type not supported:', mimeType.split('/')[1] ) + displayMessage({ + message: t('shareError.videoNotSupported', { + type: mimeType.split('/')[1] + }), + type: 'error', + theme + }) return } video = { type: mimeType.split('/')[1], uri: data } @@ -241,6 +255,13 @@ const Screens: React.FC = ({ localCorrupt }) => { 'Image type not supported:', item.mimeType.split('/')[1] ) + displayMessage({ + message: t('shareError.imageNotSupported', { + type: item.mimeType.split('/')[1] + }), + type: 'error', + theme + }) return } images.push({ type: item.mimeType.split('/')[1], uri: d }) @@ -250,6 +271,13 @@ const Screens: React.FC = ({ localCorrupt }) => { 'Video type not supported:', item.mimeType.split('/')[1] ) + displayMessage({ + message: t('shareError.videoNotSupported', { + type: item.mimeType.split('/')[1] + }), + type: 'error', + theme + }) return } video = { type: item.mimeType.split('/')[1], uri: d } diff --git a/src/components/Message.tsx b/src/components/Message.tsx index ab6c1468..4fb35c62 100644 --- a/src/components/Message.tsx +++ b/src/components/Message.tsx @@ -59,7 +59,7 @@ const displayMessage = ({ if (ref) { ref.current?.showMessage({ - duration: type === 'error' ? 5000 : duration === 'short' ? 1500 : 3000, + duration: type === 'error' ? 8000 : duration === 'short' ? 3000 : 5000, autoHide, message, description, diff --git a/src/i18n/en/screens.json b/src/i18n/en/screens.json index 2de2cc7a..b60b9e98 100644 --- a/src/i18n/en/screens.json +++ b/src/i18n/en/screens.json @@ -10,5 +10,9 @@ "pushError": { "message": "Push service error", "description": "Please re-enable push notification in settings" + }, + "shareError": { + "imageNotSupported": "Image type {{type}} not supported", + "videoNotSupported": "Video type {{type}} not supported" } } \ No newline at end of file