diff --git a/src/components/Main.js b/src/components/Main.js
index 7e7df92c..bb427359 100644
--- a/src/components/Main.js
+++ b/src/components/Main.js
@@ -20,6 +20,9 @@ THREE.ImageUtils.crossOrigin = '';
injectCSS(
'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'
);
+
+const isStreetLoaded = window.location.hash.length;
+
export default class Main extends Component {
constructor(props) {
super(props);
@@ -29,7 +32,7 @@ export default class Main extends Component {
isModalTexturesOpen: false,
isSignInModalOpened: false,
isProfileModalOpened: false,
- isScenesModalOpened: false,
+ isScenesModalOpened: !isStreetLoaded,
sceneEl: AFRAME.scenes[0],
visible: {
scenegraph: true,
@@ -227,6 +230,8 @@ export default class Main extends Component {
{
+const ScenesModal = ({ isOpen, onClose, initialTab = 'owner', delay }) => {
const { currentUser } = useAuthContext();
-
+ const [renderComponent, setRenderComponent] = useState(!delay);
const [scenesData, setScenesData] = useState([]);
const [scenesDataCommunity, setScenesDataCommunity] = useState([]);
const [totalDisplayedUserScenes, setTotalDisplayedUserScenes] =
@@ -36,7 +36,9 @@ const ScenesModal = ({ isOpen, onClose }) => {
useState(SCENES_PER_PAGE);
const [isLoadingScenes, setIsLoadingScenes] = useState(false);
const [isLoading, setIsLoading] = useState(false);
- const [selectedTab, setSelectedTab] = useState('owner');
+ const [isUserLoadedOnce, setIsUserLoadedOnce] = useState(false);
+ const [isCommunityLoadedOnce, setIsCommunityLoadedOnce] = useState(false);
+ const [selectedTab, setSelectedTab] = useState(initialTab);
const handleSceneClick = (scene) => {
if (scene.data() && scene.data().data) {
@@ -64,6 +66,16 @@ const ScenesModal = ({ isOpen, onClose }) => {
}
};
+ useEffect(() => {
+ if (delay) {
+ const timeoutId = setTimeout(() => {
+ setRenderComponent(true);
+ }, delay);
+
+ return () => clearTimeout(timeoutId);
+ }
+ }, []);
+
useEffect(() => {
const fetchData = async () => {
console.log({ scenesData, scenesDataCommunity });
@@ -144,7 +156,7 @@ const ScenesModal = ({ isOpen, onClose }) => {
}
};
- return (
+ return renderComponent ? (
{
)}
- );
+ ) : null;
};
export { ScenesModal };