Skip to content

Commit

Permalink
add listener for newTitle event
Browse files Browse the repository at this point in the history
  • Loading branch information
Algorush committed Jun 11, 2024
1 parent 598fce0 commit 56eedbb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useState } from 'react';
import styles from './SceneEditTitle.module.scss';
import { updateSceneIdAndTitle } from '../../../api/scene';
import Events from '../../../lib/Events';

const SceneEditTitle = ({ sceneData }) => {
const [title, setTitle] = useState(sceneData?.sceneTitle);
Expand All @@ -15,12 +14,9 @@ const SceneEditTitle = ({ sceneData }) => {
}, [sceneData?.sceneTitle, sceneData?.sceneId, sceneId]);

useEffect(() => {
const handleNewTitleEvent = (newTitle) => {
setTitle(newTitle);
saveNewTitle(newTitle);
};

Events.on('newtitle', handleNewTitleEvent);
AFRAME.scenes[0].addEventListener('newTitle', (event) => {
setTitle(event.detail.sceneTitle ?? '');
});
}, []);

const handleEditClick = () => {
Expand Down
4 changes: 0 additions & 4 deletions src/json-utils_1.1.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* global AFRAME, Node */
/* version: 1.0 */
import Events from './editor/lib/Events';

window.STREET = {};
var assetsUrl;
STREET.utils = {};
Expand Down Expand Up @@ -495,8 +493,6 @@ AFRAME.registerComponent('scene-title', {
titleDiv.setAttribute('id', 'sceneTitle');
titleDiv.appendChild(newContent);
document.body.append(titleDiv);
// update scene title in Editor mode
Events.emit('entityupdate', this.el);
},
updateTitleText: function (titleText) {
this.titleElement.textContent = titleText;
Expand Down

0 comments on commit 56eedbb

Please sign in to comment.