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

Refactor open preview logic #870

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

maciekstosio
Copy link
Contributor

@maciekstosio maciekstosio commented Dec 20, 2024

Fixes #278

This PR refactors logic related to opening previews. We were using showIDEPanel for RNIDE.showPanel/RNIDE.openPanel commands, the launch preview depended on the existence of the fileName and lineNumber. The problem is that VSCode passes its arguments there, but instead number in lineNumber we get an object with the panel's id, which triggers this logic always. Thus, I refactored the opening preview to use a separate command.

Additionally, startPreview was running even if the project wasn't set up yet, which led to an error that we used .project on null. Now, we open the panel and show a warning in that case.

How Has This Been Tested:

Repeat those scenarios for preview both in tab panel and side panel:

Steps:

  • Close the IDE panel
  • Reopen (or restart if in debug mode) VSCode
  • Open IDE panel from top right corner

Expected:
The panel opens without error dialog.

Steps:

  • Close the IDE panel
  • Reopen (or restart if in debug mode) VSCode
  • Click "Open preview"

Expected:
Confirm that panel opens and there is warning message

Steps:

  • Make sure IDE Panel is open
  • Click "Open preview"

Expected:
Confirm that preview started

Tested on react-native-76

Copy link

vercel bot commented Dec 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radon-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 0:11am

Copy link
Collaborator

@filip131311 filip131311 left a comment

Choose a reason for hiding this comment

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

I wonder if we shouldn't update package.json as well?
als left an inline question

await commands.executeCommand("setContext", "RNIDE.sidePanelIsClosed", false);

const panelLocation = workspace
.getConfiguration("RadonIDE")
.get<PanelLocation>("panelLocation");

if (panelLocation !== "tab") {
SidePanelViewProvider.showView(context, fileName, lineNumber);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is context not necessery in Side panel while it remains necessary in tabpanel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

showView doesn't use it at all, so I removed it 💁‍♂️

From what I quickly went through, SidePanelViewProvider gets context in the constructor and, being a static method, fails gracefully when it isn't provided. I didn't go deeper, as I assume this is outside the scope of this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair enough

Copy link
Collaborator

@filip131311 filip131311 left a comment

Choose a reason for hiding this comment

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

LGTM

@kmagiera kmagiera changed the title Refactore open preview logic Refactor open preview logic Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot read properties of undefined (reading 'project')
2 participants