Skip to content

Commit af07cf6

Browse files
committed
set receiver separately
1 parent 54d9a01 commit af07cf6

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

apps/extension/src/routes/popup/approval/transaction/use-transaction-view-switcher.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,21 @@ export const useTransactionViewSwitcher = ({
4949

5050
useEffect(() => {
5151
if (plan && wallet) {
52-
void viewTransactionPlan(
53-
plan,
54-
getMetadata,
55-
FullViewingKey.fromJsonString(wallet.fullViewingKey),
56-
).then(async txv => {
57-
setAsSender(txv);
58-
setAsPublic(asPublicTransactionView(txv));
59-
setTransactionClassification(classifyTransaction(txv));
60-
setAsReceiver(await asReceiverTransactionView(txv, { isControlledAddress }));
61-
});
52+
if (!asSender) {
53+
void viewTransactionPlan(
54+
plan,
55+
getMetadata,
56+
FullViewingKey.fromJsonString(wallet.fullViewingKey),
57+
).then(txv => {
58+
setAsSender(txv);
59+
setAsPublic(asPublicTransactionView(txv));
60+
setTransactionClassification(classifyTransaction(txv));
61+
});
62+
} else if (!asReceiver) {
63+
void asReceiverTransactionView(asSender, { isControlledAddress }).then(setAsReceiver);
64+
}
6265
}
63-
}, [plan, wallet]);
66+
}, [plan, wallet, asSender, asReceiver]);
6467

6568
const [selectedTransactionViewName, setSelectedTransactionViewName] =
6669
useState<TransactionViewTab>(TransactionViewTab.SENDER);

0 commit comments

Comments
 (0)