decentraland / decentraland/creator-hub

move scene.json data inside Project type

Open
#281 0 comments 0 reactions 0 assignees View on GitHub
3-low enhancement
Dominant language
TypeScript
Stars
7
Forks
14
Avg merge
2d 8h
Merged PRs (30d)
44

Description

### Problem:
We are currently spreading props from `scene.json` into the `Project` type to provide info about the project + scene. The problem with this approach is that whenever the `scene.json` get's updated, we need to map those updates to the Project type.
Example:
![Screenshot 2024-11-01 at 12 16 34 PM](https://github.com/user-attachments/assets/e4ae1868-e7e5-4ed6-a199-d39acf042457)

This is a bug prone approach since forgetting to map a prop will leave the in-memory Project outdated.

### Solution:
Change `Project` type to include the whole `Scene` type as `{ ...project, scene: Scene }`, and replace all the current scene.json-based props from `Project` type with getter functions so we avoid duplicating data as we do now.
By replacing current scene.json-based props I mean props like `title`, which is an alias for `scene.display?.title`, etc. Those props can instead be a `getTitle` function that returns `project.scene.display?.title || 'Some default'`.

So if an update happens to the `scene.json` file, then for updating the in-memory project and have everything in-sync this will be enough:
![Screenshot 2024-11-01 at 12 16 52 PM](https://github.com/user-attachments/assets/f05d632a-ad39-4070-a9e8-3a280e249234)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.