From fd6af5bc639080e43af722915cff637c496bc090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9lcio=20Franco?= Date: Thu, 9 Jan 2025 23:14:23 +0800 Subject: [PATCH] chore: remove unused stuff --- .../src/systems/CRX/hooks/useCurrentTab.ts | 6 ++-- .../app/src/systems/Home/pages/Home/Home.tsx | 33 ------------------- 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/packages/app/src/systems/CRX/hooks/useCurrentTab.ts b/packages/app/src/systems/CRX/hooks/useCurrentTab.ts index cb8fa06f7..ccb29b3af 100644 --- a/packages/app/src/systems/CRX/hooks/useCurrentTab.ts +++ b/packages/app/src/systems/CRX/hooks/useCurrentTab.ts @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; export function useCurrentTab() { - const [origin, setOrigin] = useState(); + const [url, setUrl] = useState(); const [faviconUrl, setFaviconUrl] = useState(); useEffect(() => { @@ -10,12 +10,12 @@ export function useCurrentTab() { chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { const currentTab = tabs[0]; setFaviconUrl(currentTab?.favIconUrl); - setOrigin(currentTab?.url); + setUrl(currentTab?.url); }); }, []); return { - origin, + url, faviconUrl, }; } diff --git a/packages/app/src/systems/Home/pages/Home/Home.tsx b/packages/app/src/systems/Home/pages/Home/Home.tsx index e0053541d..bc6c0e0b6 100644 --- a/packages/app/src/systems/Home/pages/Home/Home.tsx +++ b/packages/app/src/systems/Home/pages/Home/Home.tsx @@ -5,9 +5,7 @@ import { BalanceWidget, useAccounts } from '~/systems/Account'; import { Layout, Pages, scrollable } from '~/systems/Core'; import { useBalanceVisibility } from '~/systems/Core/hooks/useVisibility'; -import { useEffect, useState } from 'react'; import { BalanceAssets } from '~/systems/Account/components/BalanceAssets/BalanceAssets'; -import { ConnectionService } from '~/systems/DApp/services'; import { AssetsTitle, HomeActions } from '../../components'; export function Home() { @@ -23,40 +21,9 @@ export function Home() { navigate(Pages.receive()); }; - const [origin, setOrigin] = useState(null); - const [connected, setConnected] = useState(false); - - useEffect(() => { - const fetchAccount = async () => { - if (!origin) return; - const authorizedApp = await ConnectionService.getConnection(origin); - - const isAuthorizedAccount = Boolean( - account?.address && authorizedApp?.accounts.includes(account.address) - ); - - setConnected(isAuthorizedAccount); - }; - - fetchAccount(); - }, [origin, account]); - - useEffect(() => { - // Get the current tab URL - chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { - if (tabs.length > 0 && tabs[0].url) { - const url = new URL(tabs[0].url); - const port = url.port ? `:${url.port}` : ''; - const result = `${url.protocol}//${url.hostname}${port}`; - setOrigin(result); - } - }); - }, []); - return ( - {origin} isAuthorized = {connected ? 'yes' : 'no'}