diff --git a/src/App.jsx b/src/App.jsx index 0aecb07c..3acd1b69 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -364,11 +364,13 @@ const App = memo(() => { updateSegAtIndex(currentSegIndexSafe, { [type]: Math.min(Math.max(time, 0), duration) }); }, [currentSegIndexSafe, getSegApparentEnd, currentCutSeg, duration, updateSegAtIndex]); + const maxLabelLength = safeOutputFileName ? 100 : 500; + const onLabelSegmentPress = useCallback(async (index) => { const { name } = cutSegments[index]; - const value = await labelSegmentDialog(name); + const value = await labelSegmentDialog({ currentName: name, maxLength: maxLabelLength }); if (value != null) updateSegAtIndex(index, { name: value }); - }, [cutSegments, updateSegAtIndex]); + }, [cutSegments, updateSegAtIndex, maxLabelLength]); const onViewSegmentTagsPress = useCallback((segment) => { showJson5Dialog({ title: 'Segment tags', json: getSegmentTags(segment) }); @@ -900,7 +902,7 @@ const App = memo(() => { const onExportSegmentDisableAll = useCallback(() => setDisabledSegmentIds(Object.fromEntries(cutSegments.map((s) => [s.segId, true]))), [cutSegments]); const onExportSegmentEnableAll = useCallback(() => setDisabledSegmentIds({}), []); - const filenamifyOrNot = useCallback((name) => (safeOutputFileName ? filenamify(name) : name), [safeOutputFileName]); + const filenamifyOrNot = useCallback((name) => (safeOutputFileName ? filenamify(name) : name).substr(0, maxLabelLength), [safeOutputFileName, maxLabelLength]); const generateOutSegFileNames = useCallback(({ segments = enabledOutSegments, template }) => ( segments.map((segment, i) => { diff --git a/src/dialogs.jsx b/src/dialogs.jsx index 25e9eaef..4960b8f8 100644 --- a/src/dialogs.jsx +++ b/src/dialogs.jsx @@ -309,16 +309,13 @@ export function openYouTubeChaptersDialog(text) { }); } -export async function labelSegmentDialog(currentName) { +export async function labelSegmentDialog({ currentName, maxLength }) { const { value } = await Swal.fire({ showCancelButton: true, title: i18n.t('Label current segment'), inputValue: currentName, input: 'text', - inputValidator: (v) => { - const maxLength = 100; - return v.length > maxLength ? `${i18n.t('Max length')} ${maxLength}` : undefined; - }, + inputValidator: (v) => (v.length > maxLength ? `${i18n.t('Max length')} ${maxLength}` : undefined), }); return value; }