Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
mjadach-iv committed Dec 2, 2024
1 parent 1f4eb88 commit 4397c23
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/future-hopr-lib-components/PeerInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { generateBase64Jazz } from '../../utils/functions';
import CopyIcon from '@mui/icons-material/ContentCopy';
import LaunchIcon from '@mui/icons-material/Launch';


interface Props {
peerId?: string;
nodeAddress?: string;
Expand Down
17 changes: 11 additions & 6 deletions src/pages/node/channelsIncoming.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,30 +196,35 @@ function ChannelsPage() {
});
};

const peersWithAliases = (channelsIncoming || []).filter(peer => aliases && peer.peerAddress && getAliasByPeerAddress(peer.peerAddress) !== peer.peerAddress) ;
const peersWithAliases = (channelsIncoming || []).filter(
(peer) => aliases && peer.peerAddress && getAliasByPeerAddress(peer.peerAddress) !== peer.peerAddress,
);
const peersWithAliasesSorted = peersWithAliases.sort((a, b) => {
if (getAliasByPeerAddress(b.peerAddress).toLowerCase() > getAliasByPeerAddress(a.peerAddress).toLowerCase()) {
return -1;
}
if (getAliasByPeerAddress(b.peerAddress).toLowerCase() < getAliasByPeerAddress(a.peerAddress).toLowerCase()) {
return 1;
}
return 0
return 0;
});
const peersWithoutAliases = (channelsIncoming || []).filter(peer => aliases && peer.peerAddress && getAliasByPeerAddress(peer.peerAddress) === peer.peerAddress) ;
const peersWithoutAliases = (channelsIncoming || []).filter(
(peer) => aliases && peer.peerAddress && getAliasByPeerAddress(peer.peerAddress) === peer.peerAddress,
);
const peersWithoutAliasesSorted = peersWithoutAliases.sort((a, b) => {
if (b.peerAddress > a.peerAddress) {
return -1;
}
if (b.peerAddress < a.peerAddress) {
return 1;
}
return 0
return 0;
});

const peersSorted = [...peersWithAliasesSorted, ...peersWithoutAliasesSorted]
const peersSorted = [...peersWithAliasesSorted, ...peersWithoutAliasesSorted];

const parsedTableData = peersSorted.map((channel, index) => {
const parsedTableData = peersSorted
.map((channel, index) => {
const id = channel.id;
if (
!channelsIncomingObject[id].peerAddress ||
Expand Down
19 changes: 12 additions & 7 deletions src/pages/node/channelsOutgoing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,30 +189,35 @@ function ChannelsPage() {
},
];

const peersWithAliases = (channelsOutgoing || []).filter(peer => aliases && peer.peerAddress && getAliasByPeerAddress(peer.peerAddress) !== peer.peerAddress) ;
const peersWithAliases = (channelsOutgoing || []).filter(
(peer) => aliases && peer.peerAddress && getAliasByPeerAddress(peer.peerAddress) !== peer.peerAddress,
);
const peersWithAliasesSorted = peersWithAliases.sort((a, b) => {
if (getAliasByPeerAddress(b.peerAddress).toLowerCase() > getAliasByPeerAddress(a.peerAddress).toLowerCase()) {
return -1;
}
if (getAliasByPeerAddress(b.peerAddress).toLowerCase() < getAliasByPeerAddress(a.peerAddress).toLowerCase()) {
return 1;
}
return 0
return 0;
});
const peersWithoutAliases = (channelsOutgoing || []).filter(peer => aliases && peer.peerAddress && getAliasByPeerAddress(peer.peerAddress) === peer.peerAddress) ;
const peersWithoutAliases = (channelsOutgoing || []).filter(
(peer) => aliases && peer.peerAddress && getAliasByPeerAddress(peer.peerAddress) === peer.peerAddress,
);
const peersWithoutAliasesSorted = peersWithoutAliases.sort((a, b) => {
if (b.peerAddress > a.peerAddress) {
return -1;
}
if (b.peerAddress < a.peerAddress) {
return 1;
}
return 0
return 0;
});

const peersSorted = [...peersWithAliasesSorted, ...peersWithoutAliasesSorted]
const peersSorted = [...peersWithAliasesSorted, ...peersWithoutAliasesSorted];

const parsedTableData = peersSorted.map((channel, index) => {
const parsedTableData = peersSorted
.map((channel, index) => {
const id = channel.id;
if (
!channelsOutgoingObject[id].peerAddress ||
Expand All @@ -225,7 +230,7 @@ function ChannelsPage() {
const peerId = getPeerIdFromPeerAddress(peerAddress as string);

return {
id: (index+1).toString(),
id: (index + 1).toString(),
key: id,
node: (
<PeersInfo
Expand Down
22 changes: 13 additions & 9 deletions src/pages/node/peers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,32 +117,36 @@ function PeersPage() {
},
];

const peersWithAliases = (peers?.connected || []).filter(peer => aliases && peer.peerId && peerIdToAliasLink[peer.peerId]) ;
const peersWithAliases = (peers?.connected || []).filter(
(peer) => aliases && peer.peerId && peerIdToAliasLink[peer.peerId],
);
const peersWithAliasesSorted = peersWithAliases.sort((a, b) => {
if (getAliasByPeerId(b.peerId).toLowerCase() > getAliasByPeerId(a.peerId).toLowerCase()) {
return -1;
}
if (getAliasByPeerId(b.peerId).toLowerCase() < getAliasByPeerId(a.peerId).toLowerCase()) {
return 1;
}
return 0
return 0;
});
const peersWithoutAliases = (peers?.connected || []).filter(peer => aliases && peer.peerId && !peerIdToAliasLink[peer.peerId]) ;
const peersWithoutAliases = (peers?.connected || []).filter(
(peer) => aliases && peer.peerId && !peerIdToAliasLink[peer.peerId],
);
const peersWithoutAliasesSorted = peersWithoutAliases.sort((a, b) => {
if (b.peerId > a.peerId) {
return -1;
}
if (b.peerId < a.peerId) {
return 1;
}
return 0
return 0;
});

const peersSorted = [...peersWithAliasesSorted, ...peersWithoutAliasesSorted]
const peersSorted = [...peersWithAliasesSorted, ...peersWithoutAliasesSorted];

const parsedTableData = peersSorted.map((peer, index)=>{
const parsedTableData = peersSorted.map((peer, index) => {
return {
id: index+1,
id: index + 1,
node: (
<PeersInfo
peerId={peer.peerId}
Expand Down Expand Up @@ -180,8 +184,8 @@ function PeersPage() {
<SendMessageModal peerId={peer.peerId} />
</>
),
}
})
};
});

return (
<Section
Expand Down

0 comments on commit 4397c23

Please sign in to comment.