Refine photo upload messaging

This commit is contained in:
Zhiyuan Zheng 2022-06-08 21:36:18 +02:00
parent 6f414d38be
commit e37d5991cf
1 changed files with 9 additions and 4 deletions

View File

@ -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))
}
}