From 8df7d076028b766bd9dd583980ca0978565a7f7f Mon Sep 17 00:00:00 2001
From: KaWaite <34051327+KaWaite@users.noreply.github.com>
Date: Wed, 13 Dec 2023 08:43:32 +0900
Subject: [PATCH] fix(web): GlobalModal not showing when it should (#857)
---
web/src/app.tsx | 2 ++
.../features}/GlobalModal/index.tsx | 12 +++++++-----
web/src/beta/pages/Page.tsx | 2 --
3 files changed, 9 insertions(+), 7 deletions(-)
rename web/src/{classic/components/organisms => beta/features}/GlobalModal/index.tsx (79%)
diff --git a/web/src/app.tsx b/web/src/app.tsx
index 51d593f73c..fc82cc03d8 100644
--- a/web/src/app.tsx
+++ b/web/src/app.tsx
@@ -1,6 +1,7 @@
import { Suspense } from "react";
import Loading from "@reearth/beta/components/Loading";
+import GlobalModal from "@reearth/beta/features/GlobalModal";
import NotificationBanner from "@reearth/beta/features/Notification";
import { Provider as I18nProvider } from "@reearth/services/i18n";
@@ -17,6 +18,7 @@ export default function App() {
}>
+
diff --git a/web/src/classic/components/organisms/GlobalModal/index.tsx b/web/src/beta/features/GlobalModal/index.tsx
similarity index 79%
rename from web/src/classic/components/organisms/GlobalModal/index.tsx
rename to web/src/beta/features/GlobalModal/index.tsx
index 850939bf07..f1994c0da6 100644
--- a/web/src/classic/components/organisms/GlobalModal/index.tsx
+++ b/web/src/beta/features/GlobalModal/index.tsx
@@ -1,6 +1,7 @@
import { useCallback, useEffect, useState } from "react";
import { useAuth } from "@reearth/services/auth";
+import { config } from "@reearth/services/config";
import { useLang as useCurrentLang } from "@reearth/services/i18n";
import {
NotificationType,
@@ -9,7 +10,8 @@ import {
} from "@reearth/services/state";
const GlobalModal: React.FC = () => {
- const extensions = window.REEARTH_CONFIG?.extensions?.globalModal;
+ const extensions = config()?.extensions?.globalModal;
+
const { getAccessToken, logout } = useAuth();
const currentLang = useCurrentLang();
const [currentTheme] = useCurrentTheme();
@@ -18,15 +20,15 @@ const GlobalModal: React.FC = () => {
const [accessToken, setAccessToken] = useState();
useEffect(() => {
+ if (accessToken) return;
getAccessToken().then(token => {
setAccessToken(token);
});
- }, [getAccessToken]);
+ }, [accessToken, getAccessToken]);
const handleNotificationChange = useCallback(
- (type: NotificationType, text: string, heading?: string) => {
- setNotification({ type, text, heading });
- },
+ (type: NotificationType, text: string, heading?: string) =>
+ setNotification({ type, text, heading }),
[setNotification],
);
diff --git a/web/src/beta/pages/Page.tsx b/web/src/beta/pages/Page.tsx
index 84e8beb096..696e3ca89d 100644
--- a/web/src/beta/pages/Page.tsx
+++ b/web/src/beta/pages/Page.tsx
@@ -1,6 +1,5 @@
import React, { ReactNode, useMemo } from "react";
-import GlobalModal from "@reearth/classic/components/organisms/GlobalModal"; // todo: migrate to beta
import { useMeFetcher, useProjectFetcher, useSceneFetcher } from "@reearth/services/api";
import { AuthenticatedPage } from "@reearth/services/auth";
@@ -49,7 +48,6 @@ const PageWrapper: React.FC = ({ sceneId, projectId, workspaceId, renderI
) : (
<>
-
{renderItem({
sceneId,
projectId: currentProjectId,