Skip to content

Commit

Permalink
fix: reload balances after transfer is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Sep 25, 2024
1 parent ff417c4 commit 8ef512d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions frontend/src/components/TransferFundsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { request } from "src/utils/request";
type TransferFundsButtonProps = {
channels: Channel[] | undefined;
albyBalance: AlbyBalance;
reloadAlbyBalance: () => void;
onTransferComplete: () => Promise<void>;
} & ButtonProps;

export function TransferFundsButton({
channels,
albyBalance,
reloadAlbyBalance,
onTransferComplete,
children,
...props
}: TransferFundsButtonProps) {
Expand Down Expand Up @@ -46,7 +46,7 @@ export function TransferFundsButton({
"Content-Type": "application/json",
},
});
await reloadAlbyBalance();
await onTransferComplete();
toast({
title:
"🎉 Funds from Alby shared wallet transferred to your Alby Hub!",
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/screens/channels/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function Channels() {
useSyncWallet();
const { data: channels } = useChannels();
const { data: nodeConnectionInfo } = useNodeConnectionInfo();
const { data: balances } = useBalances();
const { data: balances, mutate: reloadBalances } = useBalances();
const { data: albyBalance, mutate: reloadAlbyBalance } = useAlbyBalance();
const navigate = useNavigate();
const [nodes, setNodes] = React.useState<Node[]>([]);
Expand Down Expand Up @@ -270,7 +270,10 @@ export default function Channels() {
variant="outline"
channels={channels}
albyBalance={albyBalance}
reloadAlbyBalance={reloadAlbyBalance}
onTransferComplete={async () => {
await reloadAlbyBalance();
await reloadBalances();
}}
>
Migrate
</TransferFundsButton>
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/screens/wallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { useInfo } from "src/hooks/useInfo";

function Wallet() {
const { data: info, hasChannelManagement } = useInfo();
const { data: balances } = useBalances();
const { data: balances, mutate: reloadBalances } = useBalances();
const { data: channels } = useChannels();
const { data: albyBalance, mutate: reloadAlbyBalance } = useAlbyBalance();

Expand Down Expand Up @@ -61,7 +61,10 @@ function Wallet() {
<TransferFundsButton
channels={channels}
albyBalance={albyBalance}
reloadAlbyBalance={reloadAlbyBalance}
onTransferComplete={async () => {
await reloadAlbyBalance();
await reloadBalances();
}}
>
Migrate Funds
</TransferFundsButton>
Expand Down

0 comments on commit 8ef512d

Please sign in to comment.