allow longer label names when sanitize is disabled #427

pull/841/head
Mikael Finstad 2021-08-24 01:18:05 +07:00
rodzic 490e9aa746
commit 4a1ec76a90
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 25AB36E3E81CBC26
2 zmienionych plików z 7 dodań i 8 usunięć

Wyświetl plik

@ -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) => {

Wyświetl plik

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