Skip to content

Commit

Permalink
[Video] speculative .vtt file selection fix (#5296)
Browse files Browse the repository at this point in the history
* speculative vtt fix

* add logging
  • Loading branch information
mozzius authored Sep 12, 2024
1 parent ae71f5c commit 7da3ddb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/view/com/composer/videos/SubtitleFilePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -25,9 +26,16 @@ export function SubtitleFilePicker({
const handlePick = (evt: React.ChangeEvent<HTMLInputElement>) => {
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`))
}
}
Expand Down

0 comments on commit 7da3ddb

Please sign in to comment.