Skip to content

Commit

Permalink
modify peer info
Browse files Browse the repository at this point in the history
  • Loading branch information
easylogic committed Mar 6, 2023
1 parent a59c005 commit c71e045
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions public/devtools/text.html
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ <h4 class="title">
}

function getPeerColor(peerID) {
const sortedPeersId = Object.keys(peers).sort()
const sortedPeersId = peers.map(it => it.clientID).sort()

return peerColors[sortedPeersId.findIndex(it => it === peerID)%peerColors.length];
}
Expand All @@ -951,7 +951,10 @@ <h4 class="title">

window.peers = peers;

window.peersInfo = Object.fromEntries(Object.entries(peers).map(([id, peer]) => {
window.peersInfo = Object.fromEntries(peers.map((peer) => {

const id = peer.clientID

return [id, {
id,
ticker: id.substring(id.length-2),
Expand All @@ -960,11 +963,9 @@ <h4 class="title">
}];
}));

const clientIDs = [];
const clientIDs = peers.map(it => it.clientID);

for (const [clientID, _] of Object.entries(peers)) {
clientIDs.push(clientID);
}
console.log(peersInfo);

peersHolder.innerHTML = clientIDs
.map((id) => {
Expand Down Expand Up @@ -1096,7 +1097,10 @@ <h4 class="title">
// 01-2. subscribe client event.
client.subscribe((event) => {
if (event.type === 'peers-changed') {
displayPeers(event.value[doc.getKey()], client.getID());
displayPeers(
client.getPeersByDocKey(doc.getKey()),
client.getID(),
);
}
});

Expand Down

0 comments on commit c71e045

Please sign in to comment.