Skip to content

Commit cce0d7f

Browse files
authored
Use contacts to show to/from in txn list (#283)
1 parent 8c843d2 commit cce0d7f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

renderer/components/NoteRow/NoteRow.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
import { ReactNode, useMemo } from "react";
99
import { MessageDescriptor, useIntl } from "react-intl";
1010

11+
import { TRPCRouterOutputs } from "@/providers/TRPCProvider";
1112
import { MaybeLink } from "@/ui/ChakraLink/ChakraLink";
1213
import { COLORS } from "@/ui/colors";
1314
import { ShadowCard } from "@/ui/ShadowCard/ShadowCard";
@@ -77,10 +78,12 @@ function NoteTo({
7778
to,
7879
from,
7980
type,
81+
contact,
8082
}: {
8183
to: string | string[];
8284
from: string;
8385
type: TransactionType;
86+
contact?: TRPCRouterOutputs["getContacts"][number] | undefined;
8487
}) {
8588
const { formatMessage } = useIntl();
8689

@@ -93,6 +96,7 @@ function NoteTo({
9396
color={COLORS.BLACK}
9497
_dark={{ color: COLORS.WHITE }}
9598
address={type === "send" ? to : from}
99+
addressLabel={contact?.name}
96100
/>
97101
);
98102
}
@@ -111,6 +115,7 @@ export function NoteRow({
111115
transactionHash,
112116
asTransaction = false,
113117
isBridge = false,
118+
contact,
114119
}: {
115120
accountName: string;
116121
asset?: RpcAsset;
@@ -123,6 +128,7 @@ export function NoteRow({
123128
status: TransactionStatus;
124129
memo: string | string[];
125130
transactionHash: string;
131+
contact?: TRPCRouterOutputs["getContacts"][number] | undefined;
126132
/**
127133
* Render the row as if it were a transaction (link it to the transaction details page,
128134
* show the status as the transaction's status)
@@ -160,7 +166,7 @@ export function NoteRow({
160166
{`${majorString} ${symbol}`}
161167
</Text>,
162168
<Text as="span" key={key++}>
163-
<NoteTo to={to} from={from} type={type} />
169+
<NoteTo to={to} from={from} type={type} contact={contact} />
164170
</Text>,
165171
<Text as="span" key={key++}>
166172
{formatDate(timestamp)}

renderer/components/NotesList/NotesList.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Virtuoso } from "react-virtuoso";
55
import { NoteHeadings } from "@/components/NoteRow/NoteHeadings";
66
import { NoteRow } from "@/components/NoteRow/NoteRow";
77
import { useScrollElementContext } from "@/layouts/MainLayout";
8+
import { trpcReact } from "@/providers/TRPCProvider";
89

910
import { TransactionNote } from "../../../shared/types";
1011
import { EmptyStateMessage } from "../EmptyStateMessage/EmptyStateMessage";
@@ -45,6 +46,8 @@ export function NotesList({
4546
onEndReached,
4647
}: Props) {
4748
const { formatMessage } = useIntl();
49+
const { data: contacts, isLoading: isContactsLoading } =
50+
trpcReact.getContacts.useQuery();
4851
const customScrollElement = useScrollElementContext();
4952

5053
if (isError) {
@@ -67,14 +70,16 @@ export function NotesList({
6770
);
6871
}
6972

73+
const isNotesListLoading = isLoading || isContactsLoading;
74+
7075
return (
7176
<Box>
7277
<Heading as="h2" fontSize="2xl" mb={8}>
7378
{heading}
7479
</Heading>
7580
<NoteHeadings asTransactions={asTransactions} />
76-
{isLoading && <Skeleton height="600px" />}
77-
{!isLoading && customScrollElement && (
81+
{isNotesListLoading && <Skeleton height="600px" />}
82+
{!isNotesListLoading && customScrollElement && (
7883
<Virtuoso
7984
customScrollParent={customScrollElement}
8085
data={notes}
@@ -87,6 +92,11 @@ export function NotesList({
8792
assetId={note.assetId}
8893
value={note.value}
8994
timestamp={note.timestamp}
95+
contact={contacts?.find((contact) => {
96+
return note.type === "send"
97+
? contact.address === note.to
98+
: contact.address === note.from;
99+
})}
90100
from={note.from}
91101
to={note.to}
92102
transactionHash={note.transactionHash}

0 commit comments

Comments
 (0)