Clear up how we pass around view state#2597
Merged
robertbrignull merged 2 commits intomainfrom Jul 12, 2023
Merged
Conversation
3 tasks
charisk
approved these changes
Jul 12, 2023
Contributor
charisk
left a comment
There was a problem hiding this comment.
This is great! Thank you for tidying things up and for the nice clear commits.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I realised we were passing in both
ViewStateandModeto some components. This is a mistake I made earlier and didn't realise the view state was already available.I also take the opportunity to simplify the types and avoiding passing a possibly-undefined view state around as much as possible. This shouldn't ever be undefined in practice because the first thing we do once the view is loaded is to send a
setDataExtensionEditorViewStatemessage. The fact that we have to do this is a drawback of the webview model where we have to send initialisation data only after the view is loaded. I think we can treat the brief window where the view state is undefined as a "loading" phase and display a message. This way for the rest of the code we are sure that the variable is defined. In practice this loading message is invisible and I can't spot it when the view is opened.Checklist
ready-for-doc-reviewlabel there.