Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Chou <[email protected]>
  • Loading branch information
gmaclennan and achou11 authored Nov 15, 2023
1 parent 3407e0c commit c4e18f7
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/local-peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Peer {
}
/**
* A promise that resolves when the peer connects, or rejects if it
* failes to connect
* fails to connect
*/
get connected() {
return this.#connected.promise
Expand Down Expand Up @@ -307,7 +307,7 @@ export class LocalPeers extends TypedEmitter {
async inviteResponse(peerId, options) {
await this.#waitForPendingConnections()
const peer = await this.#getPeerByDeviceId(peerId)
await peer.sendInviteResponse(options)
peer.sendInviteResponse(options)
}

/**
Expand All @@ -318,7 +318,7 @@ export class LocalPeers extends TypedEmitter {
async sendDeviceInfo(peerId, deviceInfo) {
await this.#waitForPendingConnections()
const peer = await this.#getPeerByDeviceId(peerId)
await peer.sendDeviceInfo(deviceInfo)
peer.sendDeviceInfo(deviceInfo)
}

/**
Expand Down Expand Up @@ -419,12 +419,6 @@ export class LocalPeers extends TypedEmitter {
onclose: () => {
// TODO: Track reasons for closing
peer.disconnect()
// console.log(
// 'existing',
// [...existingDevicePeers].map(
// ({ info: { protomux, ...rest } }) => rest
// )
// )
// We keep disconnected peers around, but not duplicates
if (existingDevicePeers.size > 1) {
// TODO: Decide which existing peer to delete
Expand Down Expand Up @@ -474,7 +468,6 @@ export class LocalPeers extends TypedEmitter {
const peers = new Set()
for (const devicePeers of this.#peers.values()) {
const peer = chooseDevicePeer(devicePeers)
// console.log('choose result', peer?.info)
if (peer) peers.add(peer)
}
return peers
Expand Down Expand Up @@ -646,10 +639,6 @@ function noop() {}
* @returns {undefined | Peer & { info: PeerInfoConnected | PeerInfoDisconnected }}
*/
function chooseDevicePeer(devicePeers) {
// console.log(
// 'chooseDevicePeer',
// [...devicePeers].map(({ info: { protomux, ...rest } }) => rest)
// )
if (devicePeers.size === 0) return
let [pick] = devicePeers
if (devicePeers.size > 1) {
Expand Down

0 comments on commit c4e18f7

Please sign in to comment.