Skip to content

Commit

Permalink
chore: remove unused stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
helciofranco committed Jan 9, 2025
1 parent f3996ba commit fd6af5b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 36 deletions.
6 changes: 3 additions & 3 deletions packages/app/src/systems/CRX/hooks/useCurrentTab.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react';

export function useCurrentTab() {
const [origin, setOrigin] = useState<string | undefined>();
const [url, setUrl] = useState<string | undefined>();
const [faviconUrl, setFaviconUrl] = useState<string | undefined>();

useEffect(() => {
Expand All @@ -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,
};
}
33 changes: 0 additions & 33 deletions packages/app/src/systems/Home/pages/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -23,40 +21,9 @@ export function Home() {
navigate(Pages.receive());
};

const [origin, setOrigin] = useState<string | null>(null);
const [connected, setConnected] = useState<boolean>(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 (
<Layout title="Home" isHome>
<Layout.TopBar />
{origin} isAuthorized = {connected ? 'yes' : 'no'}
<Layout.Content noBorder css={styles.content}>
<Box.Flex css={{ height: '100%', flexDirection: 'column' }}>
<BalanceWidget
Expand Down

0 comments on commit fd6af5b

Please sign in to comment.