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

fix: Remove a useless if to setShowSpinner(true) #271

Closed

Conversation

Hywan
Copy link
Contributor

@Hywan Hywan commented Nov 23, 2023

The code says: if the spinner must be shown, then let's set the spinner to be shown. This is redundant.

This patch removes the if (showSpinner) to keep only the setShowSpinner(true), as it will have the same behaviour. Even if the intend was to call setShowSpinner when showSpinner was false, it wasn't working before but will work now.

The code says: if the spinner must be shown, then let's set the spinner
to be shown. This is redundant.

This patch removes the `if (showSpinner)` to keep only the
`setShowSpinner(true)`, as it will have the same behaviour. Even if the
intend was to call `setShowSpinner` when `showSpinner` was `false`, it
wasn't working before but will work now.
@@ -86,7 +86,7 @@ export async function transpileComponent (component, opts = {}) {
let spinner;
const showSpinner = getShowSpinner();
if (opts.optimize) {
if (showSpinner) setShowSpinner(true);
setShowSpinner(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't actually redundant, because setShowSpinner internally sets the spinner show value to false. It's weird logic I know, but it does its job I think (which is to determine if the state needs to be "switched", since the spinner itself is imperatively created). optimizeComponent will then run its own spinner lifecycle, showing and hiding the spinner, after which the showSpinner value will again bubble up to the transpile operation itself.

We only want opimtimizeComponent to show the spinner if it actually already was originally being show, determined by the if (showSpinner) check.

It's convoluted sure, but the logic works!

Copy link
Collaborator

Choose a reason for hiding this comment

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

That is, if showSpinner is false I'm not sure we want to show the spinner? Specifically we need to respect opts.quiet.

@Hywan
Copy link
Contributor Author

Hywan commented Jan 18, 2024

Thanks for the triage.

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.

2 participants