mirror of https://codeberg.org/pzp/zooboard.git
Start hacking on sidebar names
This commit is contained in:
parent
618d7298e1
commit
8a696a66db
39
main.js
39
main.js
|
@ -3,6 +3,8 @@ const Path = require('node:path')
|
||||||
const URL = require('node:url')
|
const URL = require('node:url')
|
||||||
const p = require('node:util').promisify
|
const p = require('node:util').promisify
|
||||||
const awaitable = require('pull-awaitable')
|
const awaitable = require('pull-awaitable')
|
||||||
|
const iterable = require( 'pull-iterable' )
|
||||||
|
const pull = require('pull-stream')
|
||||||
const { createPeer } = require('pzp-sdk')
|
const { createPeer } = require('pzp-sdk')
|
||||||
|
|
||||||
// WARNING monkey patch! -------------------------------------------------------
|
// WARNING monkey patch! -------------------------------------------------------
|
||||||
|
@ -116,6 +118,8 @@ createPeer({ path }).then(({ peer, account: globalAccountID }) => {
|
||||||
msgIDToElemID.set(msgID, elemID)
|
msgIDToElemID.set(msgID, elemID)
|
||||||
elementsByID.set(elemID, msg.data)
|
elementsByID.set(elemID, msg.data)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log('other msg on init', msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const initialElements = [...elementsByID.values()]
|
const initialElements = [...elementsByID.values()]
|
||||||
|
@ -132,6 +136,9 @@ createPeer({ path }).then(({ peer, account: globalAccountID }) => {
|
||||||
elementsByID.set(elemID, msg.data)
|
elementsByID.set(elemID, msg.data)
|
||||||
}
|
}
|
||||||
mainWindow.webContents.send('readElements', [msg.data])
|
mainWindow.webContents.send('readElements', [msg.data])
|
||||||
|
} else if(msg?.domain === 'dict_v1__profile') {
|
||||||
|
// TODO: load on init as well
|
||||||
|
console.log('other msg on stream', msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -174,8 +181,38 @@ createPeer({ path }).then(({ peer, account: globalAccountID }) => {
|
||||||
if (hasSubscribedToConnections) return
|
if (hasSubscribedToConnections) return
|
||||||
hasSubscribedToConnections = true
|
hasSubscribedToConnections = true
|
||||||
|
|
||||||
|
//async function* recordAdded( start, end ){
|
||||||
|
// peer.db.onRecordAdded((record) => {
|
||||||
|
// yield record
|
||||||
|
// })
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
const recordsAdded = pull(
|
||||||
|
pull.count(),
|
||||||
|
pull.asyncMap((i, cb) => {
|
||||||
|
|
||||||
|
})
|
||||||
|
)
|
||||||
|
// TODO: combine peers() and onRecordAdded() into one async iterator, so we update the connections list if either there's a new connection *or* if one connected peer has a new name
|
||||||
for await (const connections of awaitable(peer.net.peers())) {
|
for await (const connections of awaitable(peer.net.peers())) {
|
||||||
mainWindow.webContents.send('connections', connections)
|
const connInfo = await Promise.all(connections.map(async (conn) => {
|
||||||
|
const [multiaddr] = conn
|
||||||
|
const parts = multiaddr.split('/')
|
||||||
|
// TODO: woops this seems to get your own name
|
||||||
|
const key = parts[parts.length - 1]
|
||||||
|
const accountId = await p(peer.db.account.find)({public: key, subdomain: 'person'})
|
||||||
|
const profile = await p(peer.dict.read)(accountId, 'profile')
|
||||||
|
const name = profile?.name
|
||||||
|
return [
|
||||||
|
conn[0],
|
||||||
|
{
|
||||||
|
...conn[1],
|
||||||
|
name,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}))
|
||||||
|
mainWindow.webContents.send('connections', connInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
package.json
14
package.json
|
@ -21,21 +21,23 @@
|
||||||
"@testing-library/user-event": "^13.5.0",
|
"@testing-library/user-event": "^13.5.0",
|
||||||
"concurrently": "^8.2.2",
|
"concurrently": "^8.2.2",
|
||||||
"debounce": "2.0",
|
"debounce": "2.0",
|
||||||
|
"pull-awaitable": "1.0.0",
|
||||||
|
"pull-iterable": "^0.1.0",
|
||||||
|
"pull-stream": "^3.7.0",
|
||||||
"pzp-caps": "^1.0.0",
|
"pzp-caps": "^1.0.0",
|
||||||
|
"pzp-conductor": "^1.0.2",
|
||||||
"pzp-db": "^1.0.2",
|
"pzp-db": "^1.0.2",
|
||||||
"pzp-dict": "^1.0.0",
|
"pzp-dict": "^1.0.0",
|
||||||
"pzp-gc": "^1.0.0",
|
"pzp-gc": "^1.0.0",
|
||||||
"pzp-goals": "^1.0.0",
|
"pzp-goals": "^1.0.0",
|
||||||
|
"pzp-hub-client": "^1.0.0",
|
||||||
|
"pzp-invite": "^1.0.0",
|
||||||
"pzp-keypair": "^1.0.0",
|
"pzp-keypair": "^1.0.0",
|
||||||
|
"pzp-net": "^1.0.1",
|
||||||
|
"pzp-promise": "^1.0.0",
|
||||||
"pzp-sdk": "^1.0.0",
|
"pzp-sdk": "^1.0.0",
|
||||||
"pzp-set": "^1.0.0",
|
"pzp-set": "^1.0.0",
|
||||||
"pzp-sync": "^1.0.0",
|
"pzp-sync": "^1.0.0",
|
||||||
"pzp-conductor": "^1.0.2",
|
|
||||||
"pzp-hub-client": "^1.0.0",
|
|
||||||
"pzp-invite": "^1.0.0",
|
|
||||||
"pzp-net": "^1.0.1",
|
|
||||||
"pzp-promise": "^1.0.0",
|
|
||||||
"pull-awaitable": "1.0.0",
|
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-outside-click-handler": "1.3.0",
|
"react-outside-click-handler": "1.3.0",
|
||||||
|
|
|
@ -22,6 +22,12 @@ dependencies:
|
||||||
pull-awaitable:
|
pull-awaitable:
|
||||||
specifier: 1.0.0
|
specifier: 1.0.0
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
pull-iterable:
|
||||||
|
specifier: ^0.1.0
|
||||||
|
version: 0.1.0
|
||||||
|
pull-stream:
|
||||||
|
specifier: ^3.7.0
|
||||||
|
version: 3.7.0
|
||||||
pzp-caps:
|
pzp-caps:
|
||||||
specifier: ^1.0.0
|
specifier: ^1.0.0
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
@ -9496,6 +9502,10 @@ packages:
|
||||||
pull-stream: 3.7.0
|
pull-stream: 3.7.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/pull-iterable@0.1.0:
|
||||||
|
resolution: {integrity: sha512-FjhQ/STYNGwQaBhmuiZspL/+PIj+OHB1lE9OteegEWzciQhkJPx6Fwt+jqcpRDJ3kTzpt/ETSo3M5TFRpZ0pgQ==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/pull-looper@1.0.0:
|
/pull-looper@1.0.0:
|
||||||
resolution: {integrity: sha512-djlD60A6NGe5goLdP5pgbqzMEiWmk1bInuAzBp0QOH4vDrVwh05YDz6UP8+pOXveKEk8wHVP+rB2jBrK31QMPA==}
|
resolution: {integrity: sha512-djlD60A6NGe5goLdP5pgbqzMEiWmk1bInuAzBp0QOH4vDrVwh05YDz6UP8+pOXveKEk8wHVP+rB2jBrK31QMPA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
@ -13,6 +13,8 @@ function Connections() {
|
||||||
setConnections(arr)
|
setConnections(arr)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
console.log('connections', connections)
|
||||||
|
// TODO: put the names into the sidebar instead of the multiaddr (if the name exists)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -30,7 +32,7 @@ function Connections() {
|
||||||
<div className="shrink-0 w-2 h-2 mb-0.5 bg-yellow-500 rounded-full mr-1" />
|
<div className="shrink-0 w-2 h-2 mb-0.5 bg-yellow-500 rounded-full mr-1" />
|
||||||
)}
|
)}
|
||||||
<div className="break-all">
|
<div className="break-all">
|
||||||
{tinyMultiaddr(multiaddr)}
|
{/*tinyMultiaddr(multiaddr)*/multiaddr}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
Loading…
Reference in New Issue