holepunch-hop 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +10 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "holepunch-hop",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "data interface to HOP",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -91,10 +91,19 @@ class HolepunchWorker extends EventEmitter {
91
91
  })
92
92
  // peer connection active
93
93
  this.Peers.on('peer-connect', (data) => {
94
+ let taskCheck = 0
95
+ let firstCheck = this.Peers.peerHolder[data]
96
+ if (firstCheck !== undefined) {
97
+ if (this.Peers.peerHolder[data]?.data?.labels !== undefined) {
98
+ taskCheck = this.Peers.peerHolder[data].data.labels.length
99
+ }
100
+ } else {
101
+ taskCheck = 0
102
+ }
94
103
  // if (this.Peers.peerHolder[data].data.boardID !== undefined) {
95
104
  // any existing peers
96
105
  let holderCheck = Object.keys(this.Peers.peerHolder)
97
- if (holderCheck.length !== 0) {
106
+ if (holderCheck !== 0 && taskCheck === 0) {
98
107
  this.Peers.writeToPublicLibrary(data)
99
108
  } else {
100
109
  this.Peers.writeTonetwork(data)