Skip to content

Commit

Permalink
fix: undefined type
Browse files Browse the repository at this point in the history
  • Loading branch information
apotdevin committed Sep 1, 2023
1 parent 48f62bb commit 54cb94b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/client/src/views/dashboard/widgets/lightning/forwards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export const ForwardListWidget = () => {
<Price amount={f.fee} />
</S.nowrap>
),
incoming: f.incoming_channel_info.node2_info.alias || '',
outgoing: f.outgoing_channel_info.node2_info.alias || '',
incoming: f.incoming_channel_info?.node2_info.alias || 'Unknown',
outgoing: f.outgoing_channel_info?.node2_info.alias || 'Unknown',
},
];
}, [] as any);
Expand Down
10 changes: 7 additions & 3 deletions src/client/src/views/forwards/forwardSankey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export const ForwardSankey: FC<{
const mapped = data.getForwards.map(d => ({
...d,
group: `${d.incoming_channel}-${d.outgoing_channel}`,
groupAlias: `${d.incoming_channel_info.node2_info.alias}-${d.outgoing_channel_info.node2_info.alias}`,
groupAlias: `${d.incoming_channel_info?.node2_info.alias || 'Unknown'}-${
d.outgoing_channel_info?.node2_info.alias || 'Unknown'
}`,
}));

const grouped = groupBy(mapped, 'groupAlias');
Expand All @@ -56,8 +58,10 @@ export const ForwardSankey: FC<{
const firstValue = value[0];

aggregated.push({
incoming_channel: firstValue.incoming_channel_info.node2_info.alias,
outgoing_channel: firstValue.outgoing_channel_info.node2_info.alias,
incoming_channel:
firstValue.incoming_channel_info?.node2_info.alias || 'Unknown',
outgoing_channel:
firstValue.outgoing_channel_info?.node2_info.alias || 'Unknown',
fee: totalFees,
tokens: totalTokens,
amount: totalAmount,
Expand Down
4 changes: 2 additions & 2 deletions src/client/src/views/forwards/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export const sortByNode = (order: string, forwardArray: Forward[]) => {
}

return {
incoming_alias: f.incoming_channel_info.node2_info.alias || '',
incoming_alias: f.incoming_channel_info?.node2_info.alias || 'Unknown',
incoming_channel: f.incoming_channel,
outgoing_alias: f.outgoing_channel_info.node2_info.alias || '',
outgoing_alias: f.outgoing_channel_info?.node2_info.alias || 'Unknown',
outgoing_channel: f.outgoing_channel,
value,
};
Expand Down
4 changes: 2 additions & 2 deletions src/client/src/views/forwards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const ForwardsList: FC<ForwardProps> = ({ days }) => {
return channelData.map(c => {
return {
...c,
incoming_name: c.incoming_channel_info.node2_info.alias || '',
outgoing_name: c.outgoing_channel_info.node2_info.alias || '',
incoming_name: c.incoming_channel_info?.node2_info.alias || 'Unknown',
outgoing_name: c.outgoing_channel_info?.node2_info.alias || 'Unknown',
};
});
}, [data]);
Expand Down
10 changes: 6 additions & 4 deletions src/client/src/views/home/reports/forwardReport/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ const countRoutes = (list: Forward[]) => {
.reduce((p: number, c: number) => p + c);

channelInfo.push({
incoming_alias: element[0].incoming_channel_info.node2_info.alias || '',
outgoing_alias: element[0].outgoing_channel_info.node2_info.alias || '',
incoming_alias:
element[0].incoming_channel_info?.node2_info.alias || 'Unknown',
outgoing_alias:
element[0].outgoing_channel_info?.node2_info.alias || 'Unknown',
incoming_channel: element[0].incoming_channel,
outgoing_channel: element[0].outgoing_channel,
route: key,
Expand Down Expand Up @@ -114,8 +116,8 @@ const countArray = (list: Forward[], type: boolean) => {
: element[0].outgoing_channel;

const alias = type
? element[0].incoming_channel_info.node2_info.alias || ''
: element[0].outgoing_channel_info.node2_info.alias || '';
? element[0].incoming_channel_info?.node2_info.alias || 'Unknown'
: element[0].outgoing_channel_info?.node2_info.alias || 'Unknown';

channelInfo.push({
alias,
Expand Down

0 comments on commit 54cb94b

Please sign in to comment.