[Video] Upload errors and UI improvements (#5092)

* surface errors in UI

* style progress indicator

* remove job status progress

* rm log

* fix webm ext
This commit is contained in:
Samuel Newman 2024-09-03 15:09:09 +01:00 committed by GitHub
parent f9d736653c
commit 0e1de19903
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 155 additions and 60 deletions

View file

@ -19,9 +19,10 @@ const VIDEO_MAX_DURATION = 90
type Props = {
onSelectVideo: (video: ImagePickerAsset) => void
disabled?: boolean
setError: (error: string) => void
}
export function SelectVideoBtn({onSelectVideo, disabled}: Props) {
export function SelectVideoBtn({onSelectVideo, disabled, setError}: Props) {
const {_} = useLingui()
const t = useTheme()
const {requestVideoAccessIfNeeded} = useVideoLibraryPermission()
@ -41,9 +42,17 @@ export function SelectVideoBtn({onSelectVideo, disabled}: Props) {
UIImagePickerPreferredAssetRepresentationMode.Current,
})
if (response.assets && response.assets.length > 0) {
onSelectVideo(response.assets[0])
try {
onSelectVideo(response.assets[0])
} catch (err) {
if (err instanceof Error) {
setError(err.message)
} else {
setError(_(msg`An error occurred while selecting the video`))
}
}
}
}, [onSelectVideo, requestVideoAccessIfNeeded])
}, [onSelectVideo, requestVideoAccessIfNeeded, setError, _])
return (
<>