-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(suite-native): FW install in onboarding flow #17111
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export * from './nativeFirmwareSlice'; | ||
export * from './components/UpdateProgressIndicatorDemo'; | ||
export * from './screens/FirmwareUpdateInProgressScreen'; | ||
export * from './components/FirmwareInstallationScreenContent'; | ||
export * from './hooks/useIsFirmwareUpdateFeatureEnabled'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { useNavigation } from '@react-navigation/native'; | ||
|
||
import { FirmwareInstallationScreenContent } from '@suite-native/firmware'; | ||
import { | ||
DeviceSettingsStackParamList, | ||
DeviceStackRoutes, | ||
Screen, | ||
StackNavigationProps, | ||
} from '@suite-native/navigation'; | ||
|
||
type NavigationProp = StackNavigationProps< | ||
DeviceSettingsStackParamList, | ||
DeviceStackRoutes.FirmwareInstallation | ||
>; | ||
|
||
export const FirmwareInstallationScreen = () => { | ||
const navigation = useNavigation<NavigationProp>(); | ||
|
||
const handleFirmwareInstallationSuccess = () => { | ||
const initialRoute = navigation.getState().routes.at(0)?.name; | ||
if (initialRoute) { | ||
navigation.navigate(initialRoute); | ||
} else { | ||
// This cause should not happen, but just to be safe | ||
navigation.popToTop(); | ||
} | ||
}; | ||
|
||
const handleFirmwareInstallationFailure = () => { | ||
navigation.navigate(DeviceStackRoutes.FirmwareUpdate); | ||
}; | ||
|
||
return ( | ||
<Screen> | ||
<FirmwareInstallationScreenContent | ||
onFirmwareInstallationSuccess={handleFirmwareInstallationSuccess} | ||
onFirmwareInstallationFailure={handleFirmwareInstallationFailure} | ||
/> | ||
</Screen> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,23 @@ | ||||||||||||||||||||||
import { FirmwareInstallationScreenContent } from '@suite-native/firmware'; | ||||||||||||||||||||||
import { Screen } from '@suite-native/navigation'; | ||||||||||||||||||||||
import { useToast } from '@suite-native/toasts'; | ||||||||||||||||||||||
|
||||||||||||||||||||||
export const FirmwareInstallationScreen = () => { | ||||||||||||||||||||||
const { showToast } = useToast(); | ||||||||||||||||||||||
const handleFirmwareInstallationSuccess = () => { | ||||||||||||||||||||||
showToast({ | ||||||||||||||||||||||
variant: 'warning', | ||||||||||||||||||||||
message: 'Firmware installation successful! TODO: redirect to the device AC screen.', | ||||||||||||||||||||||
}); | ||||||||||||||||||||||
}; | ||||||||||||||||||||||
|
||||||||||||||||||||||
return ( | ||||||||||||||||||||||
<Screen> | ||||||||||||||||||||||
<FirmwareInstallationScreenContent | ||||||||||||||||||||||
onFirmwareInstallationSuccess={handleFirmwareInstallationSuccess} | ||||||||||||||||||||||
// TODO: will be implemented as part of follow up issue: https://github.com/trezor/trezor-suite/issues/16291 | ||||||||||||||||||||||
onFirmwareInstallationFailure={() => null} | ||||||||||||||||||||||
/> | ||||||||||||||||||||||
Comment on lines
+18
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement failure handler. The failure handler is currently a no-op. While issue #16291 is tracking this, consider implementing a basic error handling flow for better user experience until the full implementation is ready. Consider implementing basic error handling: -// TODO: will be implemented as part of follow up issue: https://github.com/trezor/trezor-suite/issues/16291
-onFirmwareInstallationFailure={() => null}
+onFirmwareInstallationFailure={() => {
+ showToast({
+ variant: 'error',
+ message: 'Firmware installation failed. Please try again.',
+ });
+}} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
</Screen> | ||||||||||||||||||||||
); | ||||||||||||||||||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement actual redirection in success handler.
The success handler only shows a toast without implementing the actual redirection to the device AC screen.
Consider implementing the redirection logic:
📝 Committable suggestion