mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-20 16:38:21 +01:00
Retry dialog for errors during backup download
This commit is contained in:
@@ -18,16 +18,21 @@ export type PropsType = Readonly<{
|
||||
i18n: LocalizerType;
|
||||
currentBytes?: number;
|
||||
totalBytes?: number;
|
||||
hasError?: boolean;
|
||||
onCancel: () => void;
|
||||
onRetry: () => void;
|
||||
}>;
|
||||
|
||||
export function InstallScreenBackupImportStep({
|
||||
i18n,
|
||||
currentBytes,
|
||||
totalBytes,
|
||||
hasError,
|
||||
onCancel,
|
||||
onRetry,
|
||||
}: PropsType): JSX.Element {
|
||||
const [isConfirmingCancel, setIsConfirmingCancel] = useState(false);
|
||||
const [isConfirmingSkip, setIsConfirmingSkip] = useState(false);
|
||||
|
||||
const confirmCancel = useCallback(() => {
|
||||
setIsConfirmingCancel(true);
|
||||
@@ -42,6 +47,24 @@ export function InstallScreenBackupImportStep({
|
||||
setIsConfirmingCancel(false);
|
||||
}, [onCancel]);
|
||||
|
||||
const confirmSkip = useCallback(() => {
|
||||
setIsConfirmingSkip(true);
|
||||
}, []);
|
||||
|
||||
const abortSkip = useCallback(() => {
|
||||
setIsConfirmingSkip(false);
|
||||
}, []);
|
||||
|
||||
const onSkipWrap = useCallback(() => {
|
||||
onCancel();
|
||||
setIsConfirmingSkip(false);
|
||||
}, [onCancel]);
|
||||
|
||||
const onRetryWrap = useCallback(() => {
|
||||
onRetry();
|
||||
setIsConfirmingSkip(false);
|
||||
}, [onRetry]);
|
||||
|
||||
let progress: JSX.Element;
|
||||
let isCancelPossible = true;
|
||||
if (currentBytes != null && totalBytes != null) {
|
||||
@@ -79,6 +102,7 @@ export function InstallScreenBackupImportStep({
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="InstallScreenBackupImportStep">
|
||||
<TitlebarDragArea />
|
||||
@@ -127,6 +151,44 @@ export function InstallScreenBackupImportStep({
|
||||
{i18n('icu:BackupImportScreen__cancel-confirmation__body')}
|
||||
</ConfirmationDialog>
|
||||
)}
|
||||
|
||||
{isConfirmingSkip && (
|
||||
<ConfirmationDialog
|
||||
dialogName="InstallScreenBackupImportStep.confirmSkip"
|
||||
title={i18n('icu:BackupImportScreen__skip-confirmation__title')}
|
||||
cancelText={i18n('icu:BackupImportScreen__skip-confirmation__cancel')}
|
||||
actions={[
|
||||
{
|
||||
action: onSkipWrap,
|
||||
style: 'affirmative',
|
||||
text: i18n('icu:BackupImportScreen__skip'),
|
||||
},
|
||||
]}
|
||||
i18n={i18n}
|
||||
onClose={abortSkip}
|
||||
>
|
||||
{i18n('icu:BackupImportScreen__skip-confirmation__body')}
|
||||
</ConfirmationDialog>
|
||||
)}
|
||||
|
||||
{hasError && !isConfirmingSkip && (
|
||||
<ConfirmationDialog
|
||||
dialogName="InstallScreenBackupImportStep.error"
|
||||
title={i18n('icu:BackupImportScreen__error__title')}
|
||||
cancelText={i18n('icu:BackupImportScreen__skip')}
|
||||
actions={[
|
||||
{
|
||||
action: onRetryWrap,
|
||||
style: 'affirmative',
|
||||
text: i18n('icu:BackupImportScreen__error__confirm'),
|
||||
},
|
||||
]}
|
||||
i18n={i18n}
|
||||
onClose={confirmSkip}
|
||||
>
|
||||
{i18n('icu:BackupImportScreen__error__body')}
|
||||
</ConfirmationDialog>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user