Skip to content
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): make device switcher work without devicestate #15844

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

vytick
Copy link
Contributor

@vytick vytick commented Dec 9, 2024

Make device switcher to show content even in case there is no deviceState for the device.

Related Issue

Part of #15733

@vytick vytick added the mobile Suite Lite issues and PRs label Dec 9, 2024
@vytick vytick requested a review from a team as a code owner December 9, 2024 14:47
Copy link

github-actions bot commented Dec 9, 2024

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 20
  • More info

Learn more about 𝝠 Expo Github Action

@vytick vytick force-pushed the feat/native/device-switcher-improvements branch from e328856 to b2c1b37 Compare December 9, 2024 15:20
@@ -61,7 +61,7 @@ export const DeviceItemContent = React.memo(

const device = useSelectorDeepComparison((state: DeviceRootState) => {
// select only what is needed to avoid unnecessary rerenders
const d = selectDeviceByState(state, deviceState);
const d = deviceState ? selectDeviceByState(state, deviceState) : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -38,12 +38,13 @@ export const SimpleDeviceItemContent = React.memo(
const { applyStyle } = useNativeStyles();
const deviceIsConnected = useSelector(
// selecting only connected device property prevents unnecessary rerenders
(state: DeviceRootState) => selectDeviceByState(state, deviceState)?.connected ?? null,
(state: DeviceRootState) =>
deviceState ? selectDeviceByState(state, deviceState)?.connected : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this make any difference? selectDeviceByState returns undefined anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it expects devicestate as defined

Copy link
Contributor Author

@vytick vytick Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this calls the selector in case deviceState is defined (expected by selectDeviceByState which I didnt want to change) or returns undefined otherwise

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be fine to make selector to accept also undefined, WDYT? We will probably need it to use like this in more places no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that many places, actually. Right, it seems safe to change:

34f6539

@trezor-ci trezor-ci force-pushed the feat/native/device-switcher-improvements branch from 34f6539 to 92ffa07 Compare December 13, 2024 10:03
@trezor trezor deleted a comment from github-actions bot Dec 13, 2024
@vytick vytick merged commit 677ceff into develop Dec 13, 2024
28 checks passed
@vytick vytick deleted the feat/native/device-switcher-improvements branch December 13, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Suite Lite issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants