git ssb

16+

Dominic / patchbay



Tree: b8e8bccb7f0d43f6b02e0f1a5e8f4a2be24ab15e

Files: b8e8bccb7f0d43f6b02e0f1a5e8f4a2be24ab15e / app / page / network / connections.js

1838 bytesRaw
1const { h, computed, throttle } = require('mutant')
2
3module.exports = function Connections ({ localPeers, connectedPeers, avatar }) {
4 const state = buildState({ localPeers, connectedPeers })
5
6 return [
7 {
8 title: 'local peers',
9 body: h('LocalPeers', [
10 h('div.peers', computed(state.localPeers, peers => {
11 if (!peers.length) return h('p', 'No local peers (on same wifi/ LAN)')
12
13 return peers.map(peer => avatar(peer))
14 })),
15 h('p', [
16 h('i.fa.fa-info-circle'),
17 'these are peers on the same WiFi/LAN as you right now. You might not know some of them yet, but you can click through to find out more about them and follow them if you like.'
18 ])
19 ])
20 },
21 {
22 title: 'remote peers',
23 body: h('RemotePeers', [
24 h('div.peers', computed(state.remotePeers, peers => {
25 if (!peers.length) return h('p', 'No remote peers connected')
26
27 return peers.map(peer => avatar(peer))
28 })),
29 h('p', [
30 h('i.fa.fa-info-circle'),
31 'these are peers your\'re connecting to over the internet. You might be connected peers who you haven\'t followed (likely pubs) - this is because friends of yours might have gossiped about them, and you\'re just checking in to see if they have any news about any of your friends. If you don\'t like this, you can change it in ',
32 h('a', { href: '/settings' }, '/settings'),
33 ' under "replication"'
34 ])
35 ])
36 }
37 ]
38}
39
40function buildState ({ localPeers, connectedPeers }) {
41 const local = throttle(localPeers(), 1000)
42 const remote = computed([local, throttle(connectedPeers(), 1000)], (local, connected) => {
43 return connected.filter(peer => !local.includes(peer))
44 })
45
46 return {
47 localPeers: local,
48 remotePeers: remote
49 }
50}
51

Built with git-ssb-web