Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

feat: move news to editor page only

AykutSarac5b91fa96c710
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
index 48e0f1cc..a987c19a 100644
--- a/src/pages/_app.tsx
+++ b/src/pages/_app.tsx
@@ -6,12 +6,10 @@ import { MantineProvider } from "@mantine/core";
import { init } from "@sentry/nextjs";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Toaster } from "react-hot-toast";
-import Cookie from "universal-cookie";
import { GoogleAnalytics } from "src/components/GoogleAnalytics";
import GlobalStyle from "src/constants/globalStyle";
import { darkTheme, lightTheme } from "src/constants/theme";
import { ModalController } from "src/containers/ModalController";
-import { HerowandModal } from "src/containers/Modals/HerowandModal";
import useStored from "src/store/useStored";
if (process.env.NODE_ENV !== "development") {
@@ -22,9 +20,6 @@ if (process.env.NODE_ENV !== "development") {
});
}
-const cookie = new Cookie();
-const newsCookie = cookie.get("news_seen");
-
const queryClient = new QueryClient({
defaultOptions: {
queries: {
@@ -43,20 +38,10 @@ const monaSans = localFont({
function JsonCrack({ Component, pageProps }: AppProps) {
const [isReady, setReady] = React.useState(false);
- const [showNews, setShowNews] = React.useState(false);
const lightmode = useStored(state => state.lightmode);
React.useEffect(() => {
setReady(true);
-
- if (typeof newsCookie === "undefined") {
- setShowNews(true);
- } else setShowNews(false);
- }, []);
-
- const closeNews = React.useCallback(() => {
- setShowNews(false);
- cookie.set("news_seen", true, { path: "/", maxAge: 43200 });
}, []);
if (isReady)
@@ -66,7 +51,6 @@ function JsonCrack({ Component, pageProps }: AppProps) {
<ThemeProvider theme={lightmode ? lightTheme : darkTheme}>
<GlobalStyle />
{}
- <HerowandModal opened={showNews} onClose={closeNews} />
<MantineProvider
withGlobalStyles
withNormalizeCSS
diff --git a/src/pages/editor.tsx b/src/pages/editor.tsx
index 9a2b4fc5..6f02f683 100644
--- a/src/pages/editor.tsx
+++ b/src/pages/editor.tsx
@@ -2,9 +2,11 @@ import React from "react";
import Head from "next/head";
import { useRouter } from "next/router";
import styled from "styled-components";
+import Cookie from "universal-cookie";
import { BottomBar } from "src/containers/Editor/BottomBar";
import { Tools } from "src/containers/Editor/LiveEditor/Tools";
import Panes from "src/containers/Editor/Panes";
+import { HerowandModal } from "src/containers/Modals/HerowandModal";
import { Loading } from "src/layout/Loading";
import useJson from "src/store/useJson";
import useUser from "src/store/useUser";
@@ -26,8 +28,12 @@ export const StyledEditorWrapper = styled.div`
overflow: hidden;
`;
+const cookie = new Cookie();
+const newsCookie = cookie.get("news_seen");
+
const EditorPage: React.FC = () => {
const { isReady, query } = useRouter();
+ const [showNews, setShowNews] = React.useState(false);
const checkSession = useUser(state => state.checkSession);
const fetchJson = useJson(state => state.fetchJson);
const loading = useJson(state => state.loading);
@@ -39,8 +45,17 @@ const EditorPage: React.FC = () => {
checkSession();
fetchJson(query.json);
}
+
+ if (typeof newsCookie === "undefined") {
+ setShowNews(true);
+ } else setShowNews(false);
}, [checkSession, fetchJson, isReady, query.json]);
+ const closeNews = React.useCallback(() => {
+ setShowNews(false);
+ cookie.set("news_seen", true, { path: "/", maxAge: 43200 });
+ }, []);
+
if (loading) return <Loading message="Fetching JSON from cloud..." />;
return (
@@ -56,6 +71,7 @@ const EditorPage: React.FC = () => {
</StyledEditorWrapper>
</StyledPageWrapper>
<BottomBar />
+ <HerowandModal opened={showNews} onClose={closeNews} />
</StyledEditorWrapper>
);
};