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(ios): cache last used device #2162

Merged
merged 4 commits into from
Dec 19, 2023
Merged

feat(ios): cache last used device #2162

merged 4 commits into from
Dec 19, 2023

Conversation

szymonrybczak
Copy link
Collaborator

Summary:

Developers often have a lot of simulators installed on their machines, and if they are running --list-devices or --interactive they need to go through all of them, but by adding simple caching we'll move last used device to the top of the list.

Uploading CleanShot 2023-11-07 at 17.06.00.mp4…

Test Plan:

  1. Clone the repository and do all the required steps from the Contributing guide
  2. Run this command:
node /path/to/react-native-cli/packages/cli/build/bin.js run-ios --list-devices
  1. Choose one devices
node /path/to/react-native-cli/packages/cli/build/bin.js run-ios --list-devices
  1. Chosen device from third step should be on the top of the list.

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

): Promise<Device | undefined> {
const sortedDevices = devices;
Copy link
Member

@thymikee thymikee Dec 11, 2023

Choose a reason for hiding this comment

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

sortedDevices still references devices and is then mutated. You'd need to copy the devices array to avoid mutating it with unshift on line 49 and splice on 48

): Promise<Device | undefined> {
const sortedDevices = [...devices];
Copy link
Contributor

@cipolleschi cipolleschi Dec 18, 2023

Choose a reason for hiding this comment

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

why are these devices sorted? I don't think they are... This line seems a no-op.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not really sorted here, but I needed to create a value to do not mutate params.

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Just a nit, but overall looks good to me.

@thymikee thymikee merged commit 3945227 into main Dec 19, 2023
10 checks passed
@thymikee thymikee deleted the feat/save-last-used-device branch December 19, 2023 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants