Skip to content
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

save new scene title in JSON file #573

Merged
merged 2 commits into from
Jun 10, 2024
Merged

save new scene title in JSON file #573

merged 2 commits into from
Jun 10, 2024

Conversation

Algorush
Copy link
Collaborator

@Algorush Algorush commented Jun 8, 2024

Issue: #553
Now the title is saved in JSON and also updated in Editor mode. But there is another error related to Firebase - #532. I will fix it in another branch.

update title in Editor
@vincentfretin
Copy link
Collaborator

Is this fixing #577 too?
That's really not a good idea to update a DOM element that is handled by React.
Can't we use an effect in SceneEditTitle to listen to the newTitle event?

@kfarr kfarr merged commit 22b8894 into main Jun 10, 2024
1 check passed
@kfarr kfarr deleted the save-new-title-in-json branch June 10, 2024 16:55
@Algorush
Copy link
Collaborator Author

Algorush commented Jun 11, 2024

Can't we use an effect in SceneEditTitle to listen to the newTitle event?

But we are loading json-utils.js before the Editor code which contains Events.
I don't understand a little how this can be implemented. Now if I import 'editor/lib/Events' into SceneEditTitle.component, where I assign Events.on('newtitle' ()=> ...). And I also import Events into json-utils.js. But since json-utils is called earlier, Events is imported with an empty list of events.
Also I noticed that now when loading a saved scene with title, initially title=Undefined. But after selecting any entity, its title appears, this is not clear to me. This happens even without calling the 'newtitle' event handler

@vincentfretin
Copy link
Collaborator

Events.js on and emit functions is used only for parts of editor between aframe world and React. The newTitle event emitted in the metadata aframe component is not using that but the emit function from aframe entity. That's not the same. To register a listener for that event you need to use AFRAME.scenes[0].addEventListener('newTitle', ...).

If you see at one point the title when you select an entity, probably the SceneEditTitle react component is rerendering, you can check what going on with the props and the effect there.

@vincentfretin vincentfretin mentioned this pull request Jun 11, 2024
@Algorush
Copy link
Collaborator Author

Events.js on and emit functions is used only for parts of editor between aframe world and React. The newTitle event emitted in the metadata aframe component is not using that but the emit function from aframe entity. That's not the same. To register a listener for that event you need to use AFRAME.scenes[0].addEventListener('newTitle', ...).

Thanks for this tip. I didn’t realize at first that I could use an existing event

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants