Skip to content

Commit f94ec4d

Browse files
authored
Merge branch 'develop' into markpratt/record
2 parents 3ade38f + 3e85556 commit f94ec4d

File tree

22 files changed

+152
-114
lines changed

22 files changed

+152
-114
lines changed

localization/TranscriberAdmin-en-1.2.xliff

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,7 +2307,7 @@
23072307
</context-group>
23082308
</trans-unit>
23092309
<trans-unit id="electronImport.allDataOverwritten">
2310-
<source>All {name0} data will be overwritten.</source>
2310+
<source>All '{name0}' data will be overwritten.</source>
23112311
<target/>
23122312
<context-group>
23132313
<context context-type="sourcefile">electronImport.tsx</context>
@@ -2363,7 +2363,7 @@
23632363
</context-group>
23642364
</trans-unit>
23652365
<trans-unit id="electronImport.lastExported">
2366-
<source>Current data in audio project {name0} was last exported {date0}.</source>
2366+
<source>Current data in audio project '{name0}' was last exported {date0}.</source>
23672367
<target/>
23682368
<context-group>
23692369
<context context-type="sourcefile">electronImport.tsx</context>
@@ -2377,7 +2377,7 @@
23772377
</context-group>
23782378
</trans-unit>
23792379
<trans-unit id="electronImport.neverExported">
2380-
<source>Current data in audio project {name0} has never been exported to an itf file to preserve changes.</source>
2380+
<source>Current data in audio project '{name0}' has never been exported to an itf file to preserve changes.</source>
23812381
<target/>
23822382
<context-group>
23832383
<context context-type="sourcefile">electronImport.tsx</context>
@@ -2398,7 +2398,7 @@
23982398
</context-group>
23992399
</trans-unit>
24002400
<trans-unit id="electronImport.projectImported">
2401-
<source>Audio Project {name0} was previously imported with a newer file: {date1} </source>
2401+
<source>Audio Project '{name0}' was previously imported with a newer file: {date1} </source>
24022402
<target/>
24032403
<context-group>
24042404
<context context-type="sourcefile">electronImport.tsx</context>
@@ -6263,13 +6263,6 @@
62636263
<context context-type="sourcefile">passageRecord.tsx</context>
62646264
</context-group>
62656265
</trans-unit>
6266-
<trans-unit id="passageRecord.loadlatest">
6267-
<source>Load Latest Audio</source>
6268-
<target/>
6269-
<context-group>
6270-
<context context-type="sourcefile">passageRecord.tsx</context>
6271-
</context-group>
6272-
</trans-unit>
62736266
<trans-unit id="passageRecord.loading">
62746267
<source>Loading...</source>
62756268
<target/>

localization/TranscriberAdmin-en.xlf

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,7 @@
19801980
</unit>
19811981
<unit id="electronImport.allDataOverwritten">
19821982
<segment>
1983-
<source>All {name0} data will be overwritten.</source>
1983+
<source>All '{name0}' data will be overwritten.</source>
19841984
<target/>
19851985
</segment>
19861986
</unit>
@@ -2028,7 +2028,7 @@
20282028
</unit>
20292029
<unit id="electronImport.lastExported">
20302030
<segment>
2031-
<source>Current data in audio project {name0} was last exported {date0}.</source>
2031+
<source>Current data in audio project '{name0}' was last exported {date0}.</source>
20322032
<target/>
20332033
</segment>
20342034
</unit>
@@ -2040,7 +2040,7 @@
20402040
</unit>
20412041
<unit id="electronImport.neverExported">
20422042
<segment>
2043-
<source>Current data in audio project {name0} has never been exported to an itf file to preserve changes.</source>
2043+
<source>Current data in audio project '{name0}' has never been exported to an itf file to preserve changes.</source>
20442044
<target/>
20452045
</segment>
20462046
</unit>
@@ -2058,7 +2058,7 @@
20582058
</unit>
20592059
<unit id="electronImport.projectImported">
20602060
<segment>
2061-
<source>Audio Project {name0} was previously imported with a newer file: {date1} </source>
2061+
<source>Audio Project '{name0}' was previously imported with a newer file: {date1} </source>
20622062
<target/>
20632063
</segment>
20642064
</unit>
@@ -5368,12 +5368,6 @@
53685368
<target/>
53695369
</segment>
53705370
</unit>
5371-
<unit id="passageRecord.loadlatest">
5372-
<segment>
5373-
<source>Load Latest Audio</source>
5374-
<target/>
5375-
</segment>
5376-
</unit>
53775371
<unit id="passageRecord.loading">
53785372
<segment>
53795373
<source>Loading...</source>

src/renderer/public/localization/strings9a4d6e2b.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

src/renderer/src/business/player/usePlayerLogic.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ export const usePlayerLogic = (props: PlayerLogicProps) => {
9090
| IRegions
9191
| undefined;
9292
//might be "[]"
93-
if ((segs?.regions?.length ?? 0) < 3) {
93+
//why was this 3?
94+
if ((segs?.regions?.length ?? 0) < 2) {
9495
setCurrentSegment({ start: 0, end: durationRef.current }, -1);
9596
return true;
9697
}

src/renderer/src/components/AudioTab/AudioTab.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ export function AudioTab() {
240240
if (plan) {
241241
setPlanMedia(getMediaInPlans([plan], mediaFiles, VernacularTag, true));
242242
}
243-
// eslint-disable-next-line react-hooks/exhaustive-deps
244243
}, [mediaFiles, plan, refresh]);
245244

246245
// Check if playItem changes

src/renderer/src/components/ImportTab.tsx

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ const headerProps = {
9292
justifyContent: 'center',
9393
} as SxProps;
9494

95+
/** Successful import/sync puts a JSON change report in errMsg; hide raw JSON and malformed fragments in titles/messages. */
96+
function userVisibleImportErrMsg(errMsg: string | undefined): string {
97+
const raw = errMsg?.trim() ?? '';
98+
if (!raw) return '';
99+
if (tryParseJSON(raw) !== false) return '';
100+
const lead = raw.trimStart();
101+
if (lead.startsWith('[') || lead.startsWith('{')) return '';
102+
return raw;
103+
}
104+
95105
interface ITeamSelectorProps {
96106
selectedTeamId: string;
97107
onTeamChange: (teamId: string) => void;
@@ -171,10 +181,12 @@ interface IProps {
171181
syncBuffer?: Buffer | undefined;
172182
syncFile?: string | undefined;
173183
isOpen: boolean;
184+
offerPtf: boolean;
174185
onOpen: (val: boolean) => void;
175186
}
176187
export function ImportTab(props: IProps) {
177-
const { isOpen, onOpen, project, planName, syncBuffer, syncFile } = props;
188+
const { isOpen, onOpen, project, planName, syncBuffer, syncFile, offerPtf } =
189+
props;
178190
const t: IImportStrings = useSelector(importSelector, shallowEqual);
179191
const ta: IActivityStateStrings = useSelector(activitySelector, shallowEqual);
180192
const ts: ISharedStrings = useSelector(sharedSelector, shallowEqual);
@@ -226,6 +238,7 @@ export function ImportTab(props: IProps) {
226238
const { getOrganizedBy } = useOrganizedBy();
227239
const forceDataChanges = useDataChanges();
228240
const { handleElectronImport, getElectronImportData } = useElectronImport();
241+
const getImportFileRef = useRef(false);
229242
const headerRow = () =>
230243
t.plan +
231244
'\t' +
@@ -302,9 +315,30 @@ export function ImportTab(props: IProps) {
302315
if (isElectron && syncFile && syncBuffer) {
303316
uploadSyncITF(syncBuffer, syncFile);
304317
} // Need to ask user if they want to import PTF or ITF
305-
else setShowImportTypeSelection(true);
318+
else if (offerPtf) setShowImportTypeSelection(true);
319+
else {
320+
setSelectedImportType(isOffline ? UploadType.PTF : UploadType.ITF);
321+
if (!getImportFileRef.current)
322+
getImportFile(isOffline ? UploadType.PTF : UploadType.ITF);
323+
}
306324
}, []);
307325

326+
const getImportFile = async (type: UploadType) => {
327+
setShowImportTypeSelection(false);
328+
if (type === UploadType.PTF && isOffline) {
329+
// For offline PTF, we use electronImport which uses the Electron file picker
330+
getImportFileRef.current = true;
331+
await electronImport();
332+
getImportFileRef.current = false;
333+
} else {
334+
setUploadVisible(true);
335+
}
336+
};
337+
338+
const handleImportTypeSelected = () => {
339+
getImportFile(selectedImportType);
340+
};
341+
308342
const setImporting = (importing: boolean, errMsg?: string) => {
309343
importingRef.current = importing;
310344
setBusy(importing);
@@ -341,22 +375,6 @@ export function ImportTab(props: IProps) {
341375
} else handleActionRefused();
342376
};
343377

344-
const handleImportTypeSelected = () => {
345-
setShowImportTypeSelection(false);
346-
if (selectedImportType === UploadType.PTF && isOffline) {
347-
//this has it's own upload dialog so we don't need to setUploadVisible(true);
348-
uploadPTFOffline();
349-
} else {
350-
setUploadVisible(true);
351-
}
352-
};
353-
354-
const uploadPTFOffline = () => {
355-
// For offline PTF, we use electronImport which uses the Electron file picker
356-
electronImport();
357-
setUploadVisible(false);
358-
};
359-
360378
const handleFileUpload = (
361379
files: File[],
362380
importAction: (props: any) => void,
@@ -393,13 +411,10 @@ export function ImportTab(props: IProps) {
393411
};
394412

395413
const uploadITF = (files: File[]) => {
396-
if (!project) return;
397414
handleFileUpload(files, importProjectITFFromElectron, {
398-
projectid: remoteIdNum(
399-
'project',
400-
project,
401-
memory?.keyMap as RecordKeyMap
402-
),
415+
projectid: project
416+
? remoteIdNum('project', project, memory?.keyMap as RecordKeyMap)
417+
: 0,
403418
token,
404419
errorReporter,
405420
pendingmsg: t.importPending,
@@ -809,10 +824,11 @@ export function ImportTab(props: IProps) {
809824
//import completed ok but might have message
810825
const chdata = getChangeData(importStatus.errMsg);
811826
setChangeData([...changeData].concat(chdata));
827+
const syncExtra = userVisibleImportErrMsg(importStatus.errMsg);
812828
setImportTitle(
813829
chdata.length > 0
814830
? t.onlineChangeReport
815-
: t.importSyncDown + ' ' + importStatus.errMsg
831+
: t.importSyncDown + ' ' + syncExtra
816832
);
817833
if (remote) forceDataChanges().then(() => setImporting(false));
818834
else {
@@ -839,10 +855,8 @@ export function ImportTab(props: IProps) {
839855

840856
const statusMsg = (status: IAxiosStatus | undefined) => {
841857
if (!status || status.statusMsg === 'Import Complete') return '';
842-
return (
843-
status?.statusMsg +
844-
(status?.errMsg && status?.errMsg !== '[]' ? ': ' + status?.errMsg : '')
845-
);
858+
const extra = userVisibleImportErrMsg(status.errMsg);
859+
return status.statusMsg + (extra ? ': ' + extra : '');
846860
};
847861
return (
848862
<StyledDialog

src/renderer/src/components/PassageDetail/PassageDetailItem.tsx

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ export function PassageDetailItem(props: IProps) {
131131
);
132132
const [currentVersion, setCurrentVersion] = useState(1);
133133
const [segString, setSegString] = useState('{}');
134+
const [allowRecord, setAllowRecord] = useState(
135+
recordType !== ArtifactTypeSlug.PhraseBackTranslation
136+
);
134137
const [verses, setVerses] = useState('');
135138
const cancelled = useRef(false);
136139
const { canDoSectionStep } = useStepPermissions();
@@ -214,6 +217,12 @@ export function PassageDetailItem(props: IProps) {
214217
// eslint-disable-next-line react-hooks/exhaustive-deps
215218
}, [mediafileId, mediafiles, hasBtRecordings]);
216219

220+
useEffect(() => {
221+
if (ArtifactTypeSlug.PhraseBackTranslation === recordType)
222+
setAllowRecord(Boolean(currentSegment) && (segString || '{}') !== '{}');
223+
else setAllowRecord(true);
224+
}, [segString, recordType, currentSegment]);
225+
217226
const recordTypeId = useMemo(
218227
() => getTypeId(recordType),
219228
[recordType, getTypeId]
@@ -399,20 +408,20 @@ export function PassageDetailItem(props: IProps) {
399408
width={paneWidth}
400409
/>
401410
</Box>
402-
<Box sx={rowProp}>
403-
<Button
404-
sx={buttonProp}
405-
id="pdRecordUpload"
406-
onClick={handleUpload}
407-
title={ts.uploadMediaSingular}
408-
>
409-
<AddIcon />
410-
{ts.uploadMediaSingular}
411-
</Button>
412-
<GrowingSpacer />
413-
{currentSegment &&
414-
segString !== '{}' &&
415-
ArtifactTypeSlug.PhraseBackTranslation === recordType && (
411+
{allowRecord && (
412+
<Box sx={rowProp}>
413+
<Button
414+
sx={buttonProp}
415+
id="pdRecordUpload"
416+
onClick={handleUpload}
417+
title={ts.uploadMediaSingular}
418+
>
419+
<AddIcon />
420+
{ts.uploadMediaSingular}
421+
</Button>
422+
<GrowingSpacer />
423+
{ArtifactTypeSlug.PhraseBackTranslation ===
424+
recordType && (
416425
<TextField
417426
sx={ctlProps}
418427
id="segment"
@@ -421,7 +430,8 @@ export function PassageDetailItem(props: IProps) {
421430
label={t.segment}
422431
/>
423432
)}
424-
</Box>
433+
</Box>
434+
)}
425435
<Box sx={rowProp}>
426436
<Typography sx={statusProps}>{t.record}</Typography>
427437
{slugs.length > 1 && (
@@ -472,6 +482,7 @@ export function PassageDetailItem(props: IProps) {
472482
? JSON.stringify(getCurrentSegment())
473483
: '{}'
474484
}
485+
allowRecord={allowRecord}
475486
sourceMediaId={mediafileId}
476487
artifactId={recordTypeId}
477488
performedBy={speaker}

src/renderer/src/components/Team/TeamActions.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ const TeamActions = () => {
8686
contentStatus={contentStatus}
8787
textFieldSx={{ width: '600px' }}
8888
/>
89-
{importOpen && <ImportTab isOpen={importOpen} onOpen={setImportOpen} />}
89+
{importOpen && (
90+
<ImportTab
91+
isOpen={importOpen}
92+
onOpen={setImportOpen}
93+
offerPtf={!offline}
94+
/>
95+
)}
9096
</RootBox>
9197
);
9298
};

src/renderer/src/components/Team/TeamProjects.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const TeamProjects = () => {
3434
project={
3535
importProject ? related(importProject, 'project') : undefined
3636
} //actual project id...not plan id
37+
offerPtf={false}
3738
/>
3839
)}
3940
</>

0 commit comments

Comments
 (0)