Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,8 @@ export function FirmwareAuthenticationDialogContent({
);
}

export type IFirmwareVerifyDialogHost = Pick<typeof Dialog, 'show'>;

export function useFirmwareVerifyDialog() {
const [isLoading, setIsLoading] = useState(false);
const showFirmwareVerifyDialog = useCallback(
Expand All @@ -1049,13 +1051,20 @@ export function useFirmwareVerifyDialog() {
onContinue,
onDevSkipVerificationPress,
onClose,
dialogHost = Dialog,
}: {
device: SearchDevice | IDBDevice;
features: IOneKeyDeviceFeatures | undefined;
onContinue: (params: { checked: boolean }) => Promise<void> | void;
onClose: () => Promise<void> | void;
onVerified?: (params: { checked: boolean }) => Promise<void> | void;
onDevSkipVerificationPress?: () => void;
// A page-owned dialog host (useInPageDialog) renders this dialog into the
// page's own portal instead of the global full-window overlay. On iOS the
// global overlay stacks children by render order only, so a retry loop
// that re-mounts this dialog while the hardware checking Sheet is still
// exiting can strand a backdrop above it that swallows every tap.
dialogHost?: IFirmwareVerifyDialogHost;
}) => {
if (!deviceUtils.isFirmwareVerifySupported(device.deviceType)) {
await onContinue({ checked: false });
Expand Down Expand Up @@ -1096,7 +1105,7 @@ export function useFirmwareVerifyDialog() {
} finally {
// await backgroundApiProxy.serviceApp.hideDialogLoading();
}
const firmwareAuthenticationDialog = Dialog.show({
const firmwareAuthenticationDialog = dialogHost.show({
Comment thread
originalix marked this conversation as resolved.
tone: 'success',
icon: 'DocumentSearch2Outline',
title: ' ',
Expand Down
29 changes: 23 additions & 6 deletions packages/kit/src/views/Onboardingv2/hooks/useDeviceConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -740,18 +740,35 @@ export function useDeviceConnect({
});

if (shouldAuthenticateFirmware) {
void backgroundApiProxy.serviceHardwareUI.closeHardwareUiStateDialog({
connectId: latestDevice.connectId ?? '',
hardClose: false,
skipDelayClose: true,
deviceResetToHome: false,
});
const closeCheckingDialogForVerify = async () =>
backgroundApiProxy.serviceHardwareUI.closeHardwareUiStateDialog({
connectId: latestDevice.connectId ?? '',
hardClose: false,
skipDelayClose: true,
deviceResetToHome: false,
});
// Same handoff rule as the bootloader dialog above: wait until the
// hardware checking dialog has fully left the global iOS overlay
// before mounting the firmware verify dialog. Mounting while the old
// Sheet is still exiting can strand its overlay above the new dialog,
// and after a few genuine-check retries every tap gets swallowed.
if (platformEnv.isNativeIOS) {
await hardwareUiStateDialogLifecycle.closeAndWait(
Comment thread
originalix marked this conversation as resolved.
closeCheckingDialogForVerify,
);
} else {
void closeCheckingDialogForVerify();
}
let isVerified: boolean | undefined;
const result = await new Promise<IFirmwareVerifyResult>(
(resolve, reject) => {
void showFirmwareVerifyDialog({
device: latestDevice,
features,
// Render into the page-owned portal (when the page provides
// one) so retry rounds never interleave this dialog with the
// checking Sheet inside the render-order-only global overlay.
dialogHost: getBootloaderDialogHost?.(),
Comment thread
originalix marked this conversation as resolved.
Outdated
onVerified: ({ checked }: { checked: boolean }) => {
isVerified = checked;
setTimeout(() => {
Expand Down
Loading