From d480bb754bc335f674f004a4a3a25b6ee2775aa0 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Sat, 14 Jan 2023 12:02:50 -0800 Subject: [PATCH] some build cleanup --- net/web/src/access/admin/useAdmin.hook.js | 6 ------ net/web/src/dashboard/useDashboard.hook.js | 3 ++- net/web/src/session/Session.jsx | 11 ----------- net/web/src/session/useSession.hook.js | 12 ++++++++++++ 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/net/web/src/access/admin/useAdmin.hook.js b/net/web/src/access/admin/useAdmin.hook.js index 993209e0..d14cd538 100644 --- a/net/web/src/access/admin/useAdmin.hook.js +++ b/net/web/src/access/admin/useAdmin.hook.js @@ -34,12 +34,6 @@ export function useAdmin() { check(); }, []); - useEffect(() => { - if (app.state.adminToken) { - navigate('/dashboard'); - } - }, [app.state]); - const actions = { setPassword: (password) => { updateState({ password }); diff --git a/net/web/src/dashboard/useDashboard.hook.js b/net/web/src/dashboard/useDashboard.hook.js index dfbda6a3..b1038f03 100644 --- a/net/web/src/dashboard/useDashboard.hook.js +++ b/net/web/src/dashboard/useDashboard.hook.js @@ -1,4 +1,4 @@ -import { useContext, useRef, useState, useEffect } from 'react'; +import { useContext, useState, useEffect } from 'react'; import { getNodeConfig } from 'api/getNodeConfig'; import { setNodeConfig } from 'api/setNodeConfig'; import { getNodeAccounts } from 'api/getNodeAccounts'; @@ -42,6 +42,7 @@ export function useDashboard() { syncConfig(); syncAccounts(); } + // eslint-disable-next-line }, [app]); const actions = { diff --git a/net/web/src/session/Session.jsx b/net/web/src/session/Session.jsx index a9725187..9afa79cd 100644 --- a/net/web/src/session/Session.jsx +++ b/net/web/src/session/Session.jsx @@ -1,8 +1,5 @@ -import { useEffect, useContext } from 'react'; import { Drawer, Spin } from 'antd'; -import { useNavigate } from 'react-router-dom'; import { SessionWrapper } from './Session.styled'; -import { AppContext } from 'context/AppContext'; import { useSession } from './useSession.hook'; import { Conversation } from './conversation/Conversation'; import { Details } from './details/Details'; @@ -19,14 +16,6 @@ import { BottomNav } from './bottomNav/BottomNav'; export function Session() { const { state, actions } = useSession(); - const app = useContext(AppContext); - const navigate = useNavigate(); - - useEffect(() => { - if (!app.state.status) { - navigate('/'); - } - }, [app, navigate]); const closeAccount = () => { actions.closeProfile(); diff --git a/net/web/src/session/useSession.hook.js b/net/web/src/session/useSession.hook.js index 715d7951..5ba26db2 100644 --- a/net/web/src/session/useSession.hook.js +++ b/net/web/src/session/useSession.hook.js @@ -1,4 +1,6 @@ import { useContext, useState, useEffect, useRef } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { AppContext } from 'context/AppContext'; import { CardContext } from 'context/CardContext'; import { StoreContext } from 'context/StoreContext'; import { ViewportContext } from 'context/ViewportContext'; @@ -23,11 +25,14 @@ export function useSession() { loading: false, }); + const app = useContext(AppContext); const card = useContext(CardContext); const store = useContext(StoreContext); const viewport = useContext(ViewportContext); const channel = useContext(ChannelContext); const profile = useContext(ProfileContext); + + const navigate = useNavigate(); const storeStatus = useRef(null); const cardStatus = useRef(0); @@ -45,6 +50,13 @@ export function useSession() { } }, [card, channel, profile]); + useEffect(() => { + if (!app.state.status) { + navigate('/'); + } + // eslint-disable-next-line + }, [app.state]); + useEffect(() => { updateState({ display: viewport.state.display }); }, [viewport]);