Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reload balances, txs and channels after transfer is complete #706

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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<unknown>;
} & 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
12 changes: 9 additions & 3 deletions frontend/src/screens/channels/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ import { request } from "src/utils/request";

export default function Channels() {
useSyncWallet();
const { data: channels } = useChannels();
const { data: channels, mutate: reloadChannels } = useChannels();
rolznz marked this conversation as resolved.
Show resolved Hide resolved
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,13 @@ export default function Channels() {
variant="outline"
channels={channels}
albyBalance={albyBalance}
reloadAlbyBalance={reloadAlbyBalance}
onTransferComplete={() =>
Promise.all([
reloadAlbyBalance(),
reloadBalances(),
reloadChannels(),
])
}
>
Migrate
</TransferFundsButton>
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/screens/wallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ import { useAlbyBalance } from "src/hooks/useAlbyBalance";
import { useBalances } from "src/hooks/useBalances";
import { useChannels } from "src/hooks/useChannels";
import { useInfo } from "src/hooks/useInfo";
import { useTransactions } from "src/hooks/useTransactions";

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();
const { mutate: reloadTransactions } = useTransactions();

if (!info || !balances) {
return <Loading />;
Expand Down Expand Up @@ -61,7 +63,13 @@ function Wallet() {
<TransferFundsButton
channels={channels}
albyBalance={albyBalance}
reloadAlbyBalance={reloadAlbyBalance}
onTransferComplete={() =>
Promise.all([
reloadAlbyBalance(),
reloadBalances(),
reloadTransactions(),
])
}
>
Migrate Funds
</TransferFundsButton>
Expand Down
Loading