From 0837ba3a46ef80a23a7953fffa43e58a59acef9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Aaron?= Date: Fri, 4 Aug 2023 23:59:19 +0200 Subject: [PATCH] fix: don't render the publisher widget if there is an allowance --- src/app/screens/Home/DefaultView/index.tsx | 3 ++- src/app/screens/Home/index.tsx | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/app/screens/Home/DefaultView/index.tsx b/src/app/screens/Home/DefaultView/index.tsx index 4f1dcced1a..ac05aa058a 100644 --- a/src/app/screens/Home/DefaultView/index.tsx +++ b/src/app/screens/Home/DefaultView/index.tsx @@ -28,6 +28,7 @@ dayjs.extend(relativeTime); export type Props = { lnDataFromCurrentTab?: Battery[]; currentUrl?: URL | null; + renderPublisherWidget?: boolean; }; const DefaultView: FC = (props) => { @@ -110,7 +111,7 @@ const DefaultView: FC = (props) => { return (
- {!!props.lnDataFromCurrentTab?.length && ( + {props.renderPublisherWidget && !!props.lnDataFromCurrentTab?.length && ( )}
diff --git a/src/app/screens/Home/index.tsx b/src/app/screens/Home/index.tsx index a2a2a2a361..181175f19a 100644 --- a/src/app/screens/Home/index.tsx +++ b/src/app/screens/Home/index.tsx @@ -1,4 +1,4 @@ -import { FC, useState, useEffect, useCallback } from "react"; +import { FC, useCallback, useEffect, useState } from "react"; import browser from "webextension-polyfill"; import api from "~/common/lib/api"; import type { Allowance, Battery } from "~/types"; @@ -11,6 +11,7 @@ const Home: FC = () => { const [currentUrl, setCurrentUrl] = useState(null); const [loadingAllowance, setLoadingAllowance] = useState(true); const [lnData, setLnData] = useState([]); + const [renderDefaultView, setRenderDefaultView] = useState(false); const loadAllowance = useCallback(async () => { try { @@ -84,19 +85,25 @@ const Home: FC = () => { return null; } - if (allowance) { + if (allowance && !renderDefaultView) { return ( setAllowance(null)} + onGoBack={() => setRenderDefaultView(true)} onEditComplete={loadAllowance} onDeleteComplete={() => setAllowance(null)} /> ); } - return ; + return ( + + ); }; export default Home;