Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 42 additions & 29 deletions src/renderer/src/components/Integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import {
useCheckOnline,
integrationSlug,
useDataChanges,
useMounted,
} from '../utils';
import { localSync } from '../business/localParatext/localSync';
import { TokenContext } from '../context/TokenProvider';
Expand Down Expand Up @@ -261,6 +262,7 @@ export function IntegrationPanel(props: IProps) {

const [errorReporter] = useGlobal('errorReporter');
const { showMessage, showTitledMessage } = useSnackBar();
const isMounted = useMounted('integration');
const [busy] = useGlobal('remoteBusy'); //verified this is not used in a function 2/18/25
const [ptPath, setPtPath] = useState('');
const syncing = React.useRef<boolean>(false);
Expand Down Expand Up @@ -455,11 +457,12 @@ export function IntegrationPanel(props: IProps) {
artifactId: getTypeId(exportType),
getTranscription,
});
showMessage(translateParatextErr(err, ts) || t.syncComplete);
resetCount();
if (!isMounted())
showMessage(translateParatextErr(err, ts) || t.syncComplete);
if (setStepComplete && currentstep && !err) {
await setStepComplete(currentstep, true);
if (gotoNextStep) gotoNextStep();
if (!isMounted() && gotoNextStep) gotoNextStep();
}
setSyncing(false);
};
Expand Down Expand Up @@ -569,6 +572,16 @@ export function IntegrationPanel(props: IProps) {
/* eslint-disable-next-line react-hooks/exhaustive-deps */
}, []);

useEffect(() => {
return () => {
resetUserName();
resetProjects();
resetCount();
resetSync();
};
/* eslint-disable-next-line react-hooks/exhaustive-deps */
}, []);

useEffect(() => {
setHasParatext(false);
resetUserName();
Expand Down Expand Up @@ -619,17 +632,17 @@ export function IntegrationPanel(props: IProps) {
}, [integrations, exportType]);

useEffect(() => {
if (paratext_countStatus) {
if (paratext_countStatus.errStatus) {
if (!paratext_countStatus) return;
if (paratext_countStatus.errStatus) {
if (!isMounted())
showTitledMessage(
t.countError,
translateParatextError(paratext_countStatus, ts)
);
setCountMsg(translateParatextError(paratext_countStatus, ts));
} else if (paratext_countStatus.complete) {
setCount(paratext_count);
resetCount();
}
setCountMsg(translateParatextError(paratext_countStatus, ts));
} else if (paratext_countStatus.complete) {
setCount(paratext_count);
resetCount();
}
/* eslint-disable-next-line react-hooks/exhaustive-deps */
}, [paratext_countStatus]);
Expand All @@ -638,7 +651,7 @@ export function IntegrationPanel(props: IProps) {
if (!local) {
if (!paratext_usernameStatus) {
getUserName(accessToken || '', errorReporter, t.usernamePending);
} else if (paratext_usernameStatus.errStatus)
} else if (paratext_usernameStatus.errStatus && isMounted())
showTitledMessage(
t.usernameError,
translateParatextError(paratext_usernameStatus, ts)
Expand Down Expand Up @@ -690,7 +703,7 @@ export function IntegrationPanel(props: IProps) {
);
}
} else {
if (paratext_projectsStatus.errStatus) {
if (paratext_projectsStatus.errStatus && isMounted()) {
showTitledMessage(
t.projectError,
translateParatextError(paratext_projectsStatus, ts)
Expand All @@ -711,25 +724,25 @@ export function IntegrationPanel(props: IProps) {
}, [projectintegrations, paratext_projects, paratextIntegration, project]);

useEffect(() => {
if (paratext_syncStatus) {
if (paratext_syncStatus.errStatus) {
if (!paratext_syncStatus) return;
if (paratext_syncStatus.errStatus) {
if (isMounted())
showTitledMessage(t.syncError, TranslateSyncError(paratext_syncStatus));
resetSync();
setSyncing(false);
} else if (paratext_syncStatus.statusMsg !== '') {
showMessage(paratext_syncStatus.statusMsg);
}
if (paratext_syncStatus.complete) {
if (!paratext_syncStatus.errStatus) setCount(0); //force this to 0 now...if wrong...will reset eventually with new count
resetCount();
resetSync();
setSyncing(false);
forceDataChanges();
if (setStepComplete && currentstep && !paratext_syncStatus.errStatus) {
setStepComplete(currentstep, true).then(() => {
if (gotoNextStep) gotoNextStep();
});
}
resetSync();
setSyncing(false);
} else if (paratext_syncStatus.statusMsg !== '' && isMounted()) {
showMessage(paratext_syncStatus.statusMsg);
}
if (paratext_syncStatus.complete) {
if (!paratext_syncStatus.errStatus) setCount(0); //force this to 0 now...if wrong...will reset eventually with new count
resetCount();
resetSync();
setSyncing(false);
forceDataChanges();
if (setStepComplete && currentstep && !paratext_syncStatus.errStatus) {
setStepComplete(currentstep, true).then(() => {
if (gotoNextStep) gotoNextStep();
});
}
}
/* eslint-disable-next-line react-hooks/exhaustive-deps */
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/src/components/MediaRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,11 @@ function MediaRecord(props: IProps) {
if (blob) gotTheBlob(blob);
else blobError(ts.mediaError);
} catch (error) {
logError(Severity.error, reporter, infoMsg(error as Error, 'media load failed'));
logError(
Severity.error,
reporter,
infoMsg(error as Error, 'media load failed')
);
blobError(ts.mediaError);
}
};
Expand Down
14 changes: 9 additions & 5 deletions src/renderer/src/components/Team/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,15 @@ export const ProjectCard = (props: IProps) => {
isOpen={openIntegration}
onOpen={setOpenIntegration}
>
<IntegrationTab
isPermitted={true}
projectId={related(project, 'project')}
planId={project.id}
/>
{openIntegration ? (
<IntegrationTab
isPermitted={true}
projectId={related(project, 'project')}
planId={project.id}
/>
) : (
<></>
)}
</BigDialog>
<BigDialog
title={tpb.exportTitle.replace('{0}', getPlanName(project.id))}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/control/ProjButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const ProjButtons = (props: IProps) => {
isOpen={openIntegration}
onOpen={setOpenIntegration}
>
<IntegrationTab isPermitted={true} />
{openIntegration ? <IntegrationTab isPermitted={true} /> : <></>}
</BigDialog>
<BigDialog
title={t.exportTitle.replace('{0}', planName)}
Expand Down
Loading