fix: Remote Source Code Loading Bug #23
Merged
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.
We've encountered an issue with loading source code examples from a remote end point. In our case the playground is not rendered on the client initially. When we do open the playground, we want the code visible immediately. On the first interaction to open the playground the code is displayed as expected. However, if we close the playground and attempt to reopen it, the code is not displayed. Clicking the hide code/show code button to toggle the Playground code editor allows the code to be visible again.
The code seems to be properly loaded from the endpoint, yet its not displayed in the editor pain.
Consider the following video example:
Screen.Recording.2024-01-30.at.3.11.32.PM.mov
Solution:
After debugging is seems like the underlying code mode was being initialized to an empty array. After the files were imported from from the remote server, the underlying models were not being updated with the new file contents.
This 97b8225 re-initializes the array of models if it's an empty array and array of files contains items. With this change the code samples are properly loaded into the file viewer.
Screen.Recording.2024-01-30.at.3.51.30.PM.mov