git ssb

16+

Dominic / patchbay



Commit 3068af308439c6051b8c9e06bc9316b15827aa23

/network add "remote peers"

mixmix committed on 1/15/2019, 1:41:53 AM
Parent: a9195c696583b3d711feccb0b9ec40bc2ea10f1e

Files changed

app/page/network.jschanged
app/page/network.mcsschanged
app/page/network.jsView
@@ -17,9 +17,10 @@
1717 exports.needs = nest({
1818 'about.html.avatar': 'first',
1919 'app.sync.goTo': 'first',
2020 'sbot.obs.connection': 'first',
21- 'sbot.obs.localPeers': 'first'
21 + 'sbot.obs.localPeers': 'first',
22 + 'sbot.obs.connectedPeers': 'first'
2223 })
2324
2425 exports.create = function (api) {
2526 return nest({
@@ -43,18 +44,36 @@
4344 const page = h('NetworkPage', { title: '/network' }, [
4445 h('div.container', [
4546 h('h1', 'Network'),
4647 h('section', [
47- h('h2', 'Local Peers'),
48 + h('h2', [
49 + 'Local Peers',
50 + h('i.fa.fa-question-circle-o', { title: 'these are people 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.' })
51 + ]),
4852 computed(state.localPeers, peers => {
49- if (!peers.length) return h('p', 'There aren\'t currently any peers on the same wifi / LAN as you')
53 + if (!peers.length) return h('p', 'No local peers (on same wifi/ LAN)')
5054
5155 return peers.map(peer => api.about.html.avatar(peer))
5256 })
5357 ]),
5458 h('section', [
55- h('h2', 'Received'),
56- h('p', `Messages received per ${minsPerStep}-minute block over the last ${scale / DAY} days`),
59 + h('h2', [
60 + 'Remote Peers',
61 + h('i.fa.fa-question-circle-o', { title: 'these are peers which have fixed addresses, and are likely friends of friends (a.k.a. pubs)' })
62 + ]),
63 + computed(state.remotePeers, peers => {
64 + if (!peers.length) return h('p', 'No remote peers connected')
65 +
66 + return peers.map(peer => api.about.html.avatar(peer))
67 + })
68 + ]),
69 + h('section', [
70 + h('h2', [
71 + 'Received Messages',
72 + h('i.fa.fa-question-circle-o', {
73 + title: `Messages received per ${minsPerStep}-minute block over the last ${scale / DAY} days`
74 + })
75 + ]),
5776 canvas
5877 ])
5978 ])
6079 ])
@@ -126,12 +145,18 @@
126145 lower: latest + minsPerStep * MINUTE - scale
127146 }
128147 })
129148
149 + const localPeers = throttle(api.sbot.obs.localPeers(), 1000)
150 + const remotePeers = computed([localPeers, throttle(api.sbot.obs.connectedPeers(), 1000)], (local, connected) => {
151 + return connected.filter(peer => !local.includes(peer))
152 + })
153 +
130154 return {
131155 data,
132156 range,
133- localPeers: throttle(api.sbot.obs.localPeers(), 1000)
157 + localPeers,
158 + remotePeers
134159 }
135160 }
136161
137162 function getData ({ data, server, minsPerStep, scale }) {
app/page/network.mcssView
@@ -10,10 +10,13 @@
1010 h2 {
1111 font-size: .8rem
1212 text-transform: uppercase
1313 letter-spacing: 2px
14 +
15 + i {
16 + color: #666
17 + margin-left: .5rem
18 + }
1419 }
15- p {
16- }
1720 }
1821 }
1922 }

Built with git-ssb-web