Skip to content

feat: fetch dynamic assets and pass them on to GUI#10008

Merged
adzhindzhi merged 2 commits intodevelopfrom
feat/uepr-467-use-dynamic-assets
Feb 4, 2026
Merged

feat: fetch dynamic assets and pass them on to GUI#10008
adzhindzhi merged 2 commits intodevelopfrom
feat/uepr-467-use-dynamic-assets

Conversation

@KManolov3
Copy link
Contributor

Resolves:

https://scratchfoundation.atlassian.net/browse/UEPR-467

Changes:

Fetch dynamic assets from scratchr2 and pass them on to the editor

Matching PRs:
scratchfoundation/scratch-editor#412
https://github.com/scratchfoundation/scratchr2/pull/6780

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds functionality to fetch dynamic assets from the scratchr2 backend and pass them to the Scratch GUI editor. The implementation fetches assets from the /mediagallery/dynamic-assets/ endpoint on component mount and stores them in the component state.

Changes:

  • Added fetchDynamicAssets method to retrieve dynamic assets from the backend API
  • Initialized dynamicAssets state property and passed it as a prop to IntlGUIWithProjectHandler
  • Configured the fetch to occur on component mount via componentDidMount

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

adminPanelOpen: adminPanelOpen || false,
clientFaved: false,
clientLoved: false,
dynamicAssets: {},
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The initial state is set to an empty object, but there's no handling for the loading state. Consider adding a loading flag or checking if dynamicAssets is empty in the GUI to distinguish between 'not yet loaded' and 'loaded with no assets'.

Suggested change
dynamicAssets: {},
dynamicAssets: {},
dynamicAssetsLoading: true,

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's a design question here about whether or not to show a spinner (or something) to indicate that it's loading. That said, this specific suggestion doesn't seem necessary even if we do end up wanting a loading indicator.

Copy link
Contributor

@cwillisf cwillisf left a comment

Choose a reason for hiding this comment

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

I'd add at least console-level error reporting, but otherwise, this looks great!

adminPanelOpen: adminPanelOpen || false,
clientFaved: false,
clientLoved: false,
dynamicAssets: {},
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's a design question here about whether or not to show a spinner (or something) to indicate that it's loading. That said, this specific suggestion doesn't seem necessary even if we do end up wanting a loading indicator.

Copy link
Contributor

@adzhindzhi adzhindzhi left a comment

Choose a reason for hiding this comment

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

Looks good to me!

uri: '/mediagallery/dynamic-assets/'
}, (err, body, res) => {
if (err || (res && res.statusCode >= 400)) {
// TODO: Should we show an error message?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it’s fine to not show an error to the user here. This happens “behind the scenes” when opening the editor, and I think it would confuse users more than it would actually help 😅 That said, I agree with Copilot that it makes sense to at least log the error.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@KManolov3 KManolov3 changed the base branch from develop to release/dynamic-assets January 28, 2026 09:03
@adzhindzhi adzhindzhi changed the base branch from release/dynamic-assets to develop February 4, 2026 09:46
@adzhindzhi adzhindzhi merged commit 1df9382 into develop Feb 4, 2026
5 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants