Skip to content

Commit

Permalink
feat: Hide disconnect button in account modal (#99)
Browse files Browse the repository at this point in the history
* hide disconnect modal prop

* format

* changeset

* fix

* actual fix
  • Loading branch information
WyattMufson authored Aug 22, 2024
1 parent 62fdaa6 commit d4d5e77
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-rockets-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@treasure-dev/tdk-react": patch
---

Added the hideDisconnect prop
5 changes: 4 additions & 1 deletion examples/connect-electron/src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ function App(): JSX.Element {
return (
<>
<p>
<ConnectButton redirectUrl={`${window.location.origin}/auth/`} />
<ConnectButton
redirectUrl={`${window.location.origin}/auth/`}
hideDisconnect={true}
/>
</p>
<Versions />
</>
Expand Down
10 changes: 8 additions & 2 deletions packages/react/src/hooks/useConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getLocaleId } from "../i18n";
export type Options = ConnectModalOptions & {
supportedChainIds?: number[];
connectModalSize?: ConnectModalProps["size"];
hideDisconnect?: boolean;
};

type Props = Options;
Expand Down Expand Up @@ -61,8 +62,12 @@ const SUPPORTED_TOKENS = [
export const useConnect = (props?: Props) => {
const { chain, client, logOut, setRootElement } = useTreasure();
const { open: openWalletDetailsModal } = useWalletDetailsModal();
const { supportedChainIds, connectModalSize, ...connectModalProps } =
props ?? {};
const {
supportedChainIds,
connectModalSize,
hideDisconnect,
...connectModalProps
} = props ?? {};

const chains =
supportedChainIds && supportedChainIds.length > 0
Expand Down Expand Up @@ -93,6 +98,7 @@ export const useConnect = (props?: Props) => {
})).filter(({ address }) => address !== ZERO_ADDRESS);
return acc;
}, {} as SupportedTokens),
hideDisconnect,
onDisconnect: () => {
logOut();
},
Expand Down

0 comments on commit d4d5e77

Please sign in to comment.