From 7da3ddbe247a0b272e615a7bbbe91ba9805cb309 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 12 Sep 2024 15:16:38 +0100 Subject: [PATCH] [Video] speculative .vtt file selection fix (#5296) * speculative vtt fix * add logging --- src/view/com/composer/videos/SubtitleFilePicker.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/view/com/composer/videos/SubtitleFilePicker.tsx b/src/view/com/composer/videos/SubtitleFilePicker.tsx index 9e0fe0ae..beb3f07a 100644 --- a/src/view/com/composer/videos/SubtitleFilePicker.tsx +++ b/src/view/com/composer/videos/SubtitleFilePicker.tsx @@ -3,6 +3,7 @@ import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {logger} from '#/logger' import * as Toast from '#/view/com/util/Toast' import {atoms as a} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' @@ -25,9 +26,16 @@ export function SubtitleFilePicker({ const handlePick = (evt: React.ChangeEvent) => { const selectedFile = evt.target.files?.[0] if (selectedFile) { - if (selectedFile.type === 'text/vtt') { + if ( + selectedFile.type === 'text/vtt' || + (selectedFile.type === 'text/plain' && + selectedFile.name.endsWith('.vtt')) + ) { onSelectFile(selectedFile) } else { + logger.error('Invalid subtitle file type', { + safeMessage: `File: ${selectedFile.name} (${selectedFile.type})`, + }) Toast.show(_(msg`Only WebVTT (.vtt) files are supported`)) } }