Skip to content

Commit

Permalink
Merge pull request #7946 from LedgerHQ/bugfix/LIVE-13482-LLD-Sync-onb…
Browse files Browse the repository at this point in the history
…oarding-A-black-screen-appears-when-the-user-disconnects-their-device-during-application-installation

fix(lld): retry app installation upon device disconnection
  • Loading branch information
fAnselmi-Ledger authored Oct 22, 2024
2 parents b3746c3 + df23c6f commit cbe7a69
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-gifts-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

Retry app installation upon device disconnection
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type Props = {
setHeaderLoader: (hasLoader: boolean) => void;
onComplete: () => void;
onCancel: () => void;
onLocked: () => void;
onError: (error: Error) => void;
};

Expand All @@ -30,7 +29,6 @@ const InstallSetOfApps = ({
setHeaderLoader,
onComplete,
onCancel,
onLocked,
onError,
}: Props) => {
const { t } = useTranslation();
Expand All @@ -57,17 +55,10 @@ const InstallSetOfApps = ({
itemProgress,
progress,
opened,
isLocked,
allowManagerGranted,
isLoading,
} = status;

useEffect(() => {
if (isLocked) {
onLocked();
}
}, [isLocked, onLocked]);

useEffect(() => {
if (error instanceof UserRefusedAllowManager) {
onCancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Props = {
deviceToRestore?: DeviceModelInfo | null | undefined;
setHeaderLoader: (hasLoader: boolean) => void;
onComplete: () => void;
onError: (error: Error) => void;
onError?: (error: Error) => void;
};

/**
Expand Down Expand Up @@ -65,25 +65,29 @@ const OnboardingAppInstallStep = ({
const handleRetry = useCallback(() => {
setCancelModalOpen(false);
setLockedModalOpen(false);
setInProgress(true);
}, []);

const handleCancel = useCallback(() => {
setInProgress(false);
setCancelModalOpen(true);
}, []);

const handleLocked = useCallback(() => {
setInProgress(false);
setLockedModalOpen(true);
}, []);

const handleError = useCallback(
(error: Error) => {
if (onError) {
onError(error);
} else {
setHeaderLoader(false);
setInProgress(false);
const errorActions = new Map<string, () => void>([
["LockedDeviceError", () => setLockedModalOpen(true)],
["default", () => setCancelModalOpen(true)],
]);
(errorActions.get(error.name) || errorActions.get("default"))!();
}
},
[onError],
[setHeaderLoader, onError],
);

const handlePressSkip = useCallback(() => {
Expand Down Expand Up @@ -158,7 +162,6 @@ const OnboardingAppInstallStep = ({
setHeaderLoader={setHeaderLoader}
onComplete={handleInstallComplete}
onCancel={handleCancel}
onLocked={handleLocked}
onError={handleError}
/>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ const SyncOnboardingCompanion: React.FC<SyncOnboardingCompanionProps> = ({
deviceToRestore={shouldRestoreApps && deviceToRestore ? deviceToRestore : undefined}
setHeaderLoader={(hasLoader: boolean) => setHasAppLoader(hasLoader)}
onComplete={handleInstallRecommendedApplicationComplete}
onError={handleInstallRecommendedApplicationComplete}
/>
),
},
Expand Down

0 comments on commit cbe7a69

Please sign in to comment.