Skip to content

Commit

Permalink
fix(web): GlobalModal not showing when it should (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaWaite committed Dec 12, 2023
1 parent 5740377 commit 8df7d07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions web/src/app.tsx
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -17,6 +18,7 @@ export default function App() {
<I18nProvider>
<Suspense fallback={<Loading animationSize={80} animationColor="#3B3CD0" />}>
<NotificationBanner />
<GlobalModal />
<AppRoutes />
</Suspense>
</I18nProvider>
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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();
Expand All @@ -18,15 +20,15 @@ const GlobalModal: React.FC = () => {
const [accessToken, setAccessToken] = useState<string>();

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],
);

Expand Down
2 changes: 0 additions & 2 deletions web/src/beta/pages/Page.tsx
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -49,7 +48,6 @@ const PageWrapper: React.FC<Props> = ({ sceneId, projectId, workspaceId, renderI
<Loading animationSize={80} />
) : (
<>
<GlobalModal />
{renderItem({
sceneId,
projectId: currentProjectId,
Expand Down

0 comments on commit 8df7d07

Please sign in to comment.