Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 classic menu conversion process #38858
Refactor classic menu conversion process #38858
Changes from all commits
b0a7d1d
124e244
ffa8a7e
34974ac
c8a8e1c
8161482
651ed4c
27d0a94
6fad279
04bdbc2
35cbf10
864a469
987c38f
31ccf02
5ae5df7
bf69385
ef9b3d7
ca5eeb5
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
No showing a placeholder if we're running the conversion process.
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.
Now
loading
UI state should show immediately if we are running the conversion.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.
These messages are pretty helpful, should we also add them as snackbar notifications? (In a different PR)
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.
We could yes if that's not too "noisy"? I wonder if notification popups have
speak()
built in?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.
Actually I've found a great case where that would be very useful. When creating an empty menu it's not clear that it's been "successful". An explicit confirmation would be really helpful.
I'm working on a sister PR now which I will push up which refactors the create empty process.
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.
I'd pull it out of the hook, there's no need to construct a new function on each run and it would be more readable to me (more separation).
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.
I take your point but if you follow the flow you'll notice that this is required to be within a hook because it uses other hooks. In fact it's hooks within hooks within hooks.
I'm not in favour of this approach really but I don't think we should look to refactor in this PR because it will become overly complex to review.
How would you feel about pairing on a refactor of this sometime?
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.
Sure, let's try to pair up tomorrow
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.
With the recent updates in place I feel pretty good about having this here, let's just wrap it in
useCallback
.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.
You can have an async function inside useCallback, only you have to declare it separately, e.g.:
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.
Yeh but in this case the aim isn't to return
Promise
fromconvert()
. We want to run a routine and then have that routine update thestate
which we can then use outside of the hook to decide on various things such as loading states.This relieves the hook consumer from having to reimplementing the
isFetching
,isError
...etc inside their component. Rather all this is encapsulated and we simply expose a state which the consumer can use to decide on side effects within auseEffect
.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.
All I'm saying is there are two code styles available to choose from. Note that my snippet above doesn't return a promise either.
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.
Oh I see. You're just saying we could move the async function outside of the
useCallback
and that would be ok.Unless it's a blocker for you, I'd rather not do that now because I'm planning a follow up that might change things a little. I ping you when that's up.
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.
nit, this could say just
throw err
since we're not going to tell the user what the error message says.