Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
mjadach-iv committed Dec 3, 2024
1 parent 6e804f2 commit 69f2cdc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 24 deletions.
7 changes: 6 additions & 1 deletion src/future-hopr-lib-components/PeerInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ const PeersInfo: React.FC<Props> = (props) => {
const getAliasByPeerId = (peerId: string): string | JSX.Element => {
const shortPeerId = peerId && `${peerId.substring(0, 6)}...${peerId.substring(peerId.length - 8, peerId.length)}`;
const displayPeerId = props.shortenPeerId ? shortPeerId : peerId;
if (aliases && peerId && peerIdToAliasLink[peerId]) return <><strong>{peerIdToAliasLink[peerId]}</strong> ({displayPeerId})</>;
if (aliases && peerId && peerIdToAliasLink[peerId])
return (
<>
<strong>{peerIdToAliasLink[peerId]}</strong> ({displayPeerId})
</>
);
return displayPeerId;
};

Expand Down
23 changes: 14 additions & 9 deletions src/pages/node/aliases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,19 @@ function AliasesPage() {
const parsedTableData = Object.entries(aliases ?? {}).map(([alias, peerId], key) => {
const peerAddress = getNodeAddressByPeerId(peerId);
const lastSeenNumeric = peerId && peersObject[peerId]?.lastSeen;
const lastSeen = lastSeenNumeric as number > 0 ? new Date(lastSeenNumeric).toLocaleString('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
timeZoneName: 'short',
}).replace(', ', '\n') : 'Not seen';
const lastSeen =
(lastSeenNumeric as number) > 0
? new Date(lastSeenNumeric)
.toLocaleString('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
timeZoneName: 'short',
})
.replace(', ', '\n')
: 'Not seen';

return {
id: peerId,
Expand All @@ -143,7 +148,7 @@ function AliasesPage() {
nodeAddress={peerAddress ?? ''}
/>
),
lastSeen: <span style={{whiteSpace: 'break-spaces'}}>{peerId === hoprAddress ? '-' : lastSeen}</span>,
lastSeen: <span style={{ whiteSpace: 'break-spaces' }}>{peerId === hoprAddress ? '-' : lastSeen}</span>,
peerId,
peerAddress: peerAddress ?? '',
actions: (
Expand Down
21 changes: 13 additions & 8 deletions src/pages/node/peers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,19 @@ function PeersPage() {
const peersSorted = [...peersWithAliasesSorted, ...peersWithoutAliasesSorted];

const parsedTableData = peersSorted.map((peer, index) => {
const lastSeen = peer.lastSeen as number > 0 ? new Date(peer.lastSeen).toLocaleString('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
timeZoneName: 'short',
}).replace(', ', '\n') : 'Not seen';
const lastSeen =
(peer.lastSeen as number) > 0
? new Date(peer.lastSeen)
.toLocaleString('en-US', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
timeZoneName: 'short',
})
.replace(', ', '\n')
: 'Not seen';

return {
id: index + 1,
Expand Down
4 changes: 2 additions & 2 deletions src/store/slices/node/actionsAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1193,15 +1193,15 @@ export const createAsyncReducer = (builder: ActionReducerMapBuilder<typeof initi
// Generate links
for (let i = 0; i < action.payload.connected.length; i++) {
const node = action.payload.connected[i];
if(node.peerId && node.peerAddress){
if (node.peerId && node.peerAddress) {
state.links.nodeAddressToPeerId[node.peerAddress] = node.peerId;
state.links.peerIdToNodeAddress[node.peerId] = node.peerAddress;
}
state.peers.parsed.connected[node.peerId] = node;
}
for (let i = 0; i < action.payload.announced.length; i++) {
const node = action.payload.announced[i];
if(node.peerId && node.peerAddress){
if (node.peerId && node.peerAddress) {
state.links.nodeAddressToPeerId[node.peerAddress] = node.peerId;
state.links.peerIdToNodeAddress[node.peerId] = node.peerAddress;
}
Expand Down
8 changes: 4 additions & 4 deletions src/store/slices/node/initialState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,17 @@ type InitialState = {
quality: number;
multiaddr: string | null;
heartbeats: {
sent: number;
success: number;
sent: number;
success: number;
};
lastSeen: number;
lastSeenLatency: number;
backoff: number;
isNew: boolean;
reportedVersion: string;
};
}
}
};
};
isFetching: boolean;
alreadyFetched: boolean;
};
Expand Down

0 comments on commit 69f2cdc

Please sign in to comment.