From 56eedbba44a3634e974aefb67832803f07c5a8b4 Mon Sep 17 00:00:00 2001 From: Alexander Goryushkin Date: Tue, 11 Jun 2024 12:27:58 -0400 Subject: [PATCH] add listener for newTitle event --- .../SceneEditTitle/SceneEditTitle.component.jsx | 10 +++------- src/json-utils_1.1.js | 4 ---- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/editor/components/components/SceneEditTitle/SceneEditTitle.component.jsx b/src/editor/components/components/SceneEditTitle/SceneEditTitle.component.jsx index 9ce85021d..1814eff39 100644 --- a/src/editor/components/components/SceneEditTitle/SceneEditTitle.component.jsx +++ b/src/editor/components/components/SceneEditTitle/SceneEditTitle.component.jsx @@ -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); @@ -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 = () => { diff --git a/src/json-utils_1.1.js b/src/json-utils_1.1.js index 303e2b8c3..215d79b59 100644 --- a/src/json-utils_1.1.js +++ b/src/json-utils_1.1.js @@ -1,7 +1,5 @@ /* global AFRAME, Node */ /* version: 1.0 */ -import Events from './editor/lib/Events'; - window.STREET = {}; var assetsUrl; STREET.utils = {}; @@ -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;