-
Notifications
You must be signed in to change notification settings - Fork 1
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 loading last selected deployment #2460
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Ah I think I understand. These were not awaited here, and awaiting on the selection above caused this to work since
refreshAll
is used in initialization. So this looks like a timing issue. If I'm on the wrong track please let me know.It may be beneficial to instead surround these in a
await Promise.all
and then won't need to pass the resources.Alternatively we could require passing the resources and make those methods synchronous, but that is a larger change.
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.
Close but there's more to it, the main reason is having the content record in state when
this.updateWebViewView...
methods are called, it is more an "order of operations" problem.So,
state.getSelectedContentRecord
pulls record and stores in memory atstate.contentRecords
updateWebViewViewContentRecords
makes use of the record in stateIt is true that
refreshActiveContentRecord
andrefreshActiveConfig
now also callgetSelected...
and another option was to move those calls beforethis.updateWebViewView...
, but since those methods do some other operations I found it safer to have an optional param and receive the pre-fetched record.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'm still not sure that I understand either. It really does feel like a bit of a timing issue in which we are simply being more explicit to make sure it doesn't happen, but... why did the timing issue not occur in the original code when we had an event bus?
Was this because the event bus has an implicit order of execution because messages were inserted into a FIFO queue, so it was not an issue?
I'm sure you're on the right track here, but I'd feel easier about this if I understood this impact, as I'm a little worried we might also have some other impacts from the change which may not have surfaced yet in our testing.
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.
Thanks for the explanation @marcosnav I totally understand the change now.
@sagerb let me see if I can explain in a different way.
updateWebViewViewContentRecords
just sends the message to the webview with the current state ofstate.contentRecords
, butstate.getSelectedContentRecord()
actually updatesstate.contentRecords
with the newest data from the API. It is similar for the configuration code.The
onInitializingMsg
function callsrefreshAll
withforceAll = false
to optimize initial load times; avoiding retrieving all content records and configurations when we only need the last ones used. So if we don't callstate.getSelected...
we actually don't call the grab the previous selection from the workspace state and call the API.The removal of the bus actually removed these calls: d8eb18a#diff-f129ed54e45c65dc728784d713300ce0800add2ee009330128624da760d3ff4eL1480
So this wasn't a timing issue due to the removed bus, but an accidental removal of logic.
I'll mark as approved @marcosnav! 🙇
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.
Ah, thank you!