git ssb

10+

Matt McKegg / patchwork



Commit 339a023bbaaa61ba00aff4dafebc56391660606d

add force disconnect button on connected pubs

Matt McKegg committed on 12/12/2017, 8:23:16 PM
Parent: dee627bd4c8dda263ef6736bbe0bc2516f802a0e

Files changed

locales/en.jsonchanged
modules/page/html/render/public.jschanged
sbot/index.jschanged
styles/dark/profile-list.mcsschanged
styles/light/profile-list.mcsschanged
locales/en.jsonView
@@ -188,6 +188,7 @@
188188 "Unread Message": "Unread Message",
189189 "Font Size": "Font Size",
190190 "Public Feed Options": "Public Feed Options",
191191 "Only include posts from subscribed channels": "Only include posts from subscribed channels",
192- "Default": "Default"
193-}
192 + "Default": "Default",
193 + "Force Disconnect": "Force Disconnect"
194 +}
modules/page/html/render/public.jsView
@@ -1,14 +1,15 @@
11 var nest = require('depnest')
22 var extend = require('xtend')
33 var pull = require('pull-stream')
4-var { h, send, when, computed, map } = require('mutant')
4 +var { h, send, when, computed, map, onceTrue } = require('mutant')
55
66 exports.needs = nest({
77 sbot: {
88 obs: {
99 connectedPeers: 'first',
10- localPeers: 'first'
10 + localPeers: 'first',
11 + connection: 'first'
1112 }
1213 },
1314 'sbot.pull.stream': 'first',
1415 'feed.pull.public': 'first',
@@ -238,8 +239,11 @@
238239 h('div.name', [ api.about.obs.name(id) ])
239240 ]),
240241 h('div.progress', [
241242 api.progress.html.peer(id)
243 + ]),
244 + h('div.controls', [
245 + h('a.disconnect', {href: '#disconnect', 'ev-click': send(disconnect, id), title: i18n('Force Disconnect')}, ['x'])
242246 ])
243247 ])
244248 })
245249 ])
@@ -260,8 +264,14 @@
260264 channel: id,
261265 subscribed: false
262266 })
263267 }
268 +
269 + function disconnect (id) {
270 + onceTrue(api.sbot.obs.connection, (sbot) => {
271 + sbot.patchwork.disconnect(id)
272 + })
273 + }
264274 }
265275 }
266276
267277 function getType (msg) {
sbot/index.jsView
@@ -6,8 +6,9 @@
66 var Search = require('./search')
77 var RecentFeeds = require('./recent-feeds')
88 var LiveBacklinks = require('./live-backlinks')
99 var pull = require('pull-stream')
10 +var ref = require('ssb-ref')
1011
1112 exports.name = 'patchwork'
1213 exports.version = require('../package.json').version
1314 exports.manifest = {
@@ -26,9 +27,11 @@
2627 liveBacklinks: {
2728 subscribe: 'sync',
2829 unsubscribe: 'sync',
2930 stream: 'source'
30- }
31 + },
32 +
33 + disconnect: 'async'
3134 }
3235
3336 exports.init = function (ssb, config) {
3437 var progress = Progress(ssb, config)
@@ -62,7 +65,19 @@
6265 recentFeeds: recentFeeds.stream,
6366 linearSearch: search.linear,
6467 getSubscriptions: subscriptions.get,
6568 getChannels: channels.get,
66- liveBacklinks: LiveBacklinks(ssb, config)
69 + liveBacklinks: LiveBacklinks(ssb, config),
70 +
71 + disconnect: function (opts, cb) {
72 + if (ref.isFeed(opts)) opts = {key: opts}
73 + if (opts && (opts.key || opts.host)) {
74 + ssb.gossip.peers().find(peer => {
75 + if (peer.state === 'connected' && (peer.key === opts.key || peer.host === opts.host)) {
76 + ssb.gossip.disconnect(peer, cb)
77 + return true
78 + }
79 + })
80 + }
81 + }
6782 }
6883 }
styles/dark/profile-list.mcssView
@@ -32,12 +32,8 @@
3232 height: 12px
3333 content: "<circle cx='6' stroke='#888' fill='none' cy='6' r='5' /> <circle cx='6' cy='6' r='3' fill='#888'/>"
3434 }
3535
36- :hover {
37- background-color: #434141;
38- }
39-
4036 div.avatar {
4137 img {
4238 width: 40px
4339 height: 40px
@@ -72,6 +68,41 @@
7268 width: 20px
7369 flex: 1
7470 }
7571 }
72 +
73 + div.controls {
74 + opacity: 0
75 + position: absolute
76 + right: 7px
77 + top: 0
78 + bottom: 0
79 + display: flex;
80 + justify-content: center;
81 + flex-direction: column;
82 + width: 15px;
83 + transition: opacity 0.2s
84 + a.disconnect {
85 + color: white;
86 + border-radius: 10px;
87 + height: 16px;
88 + width: 16px;
89 + background-color: #777
90 + text-align: center
91 + vertical-align: middle
92 + font-size: 14px;
93 + overflow: hidden;
94 + :hover {
95 + text-decoration: none
96 + background-color: #F77
97 + }
98 + }
99 + }
100 +
101 + :hover {
102 + background-color: #434141;
103 + div.controls {
104 + opacity: 1
105 + }
106 + }
76107 }
77108 }
styles/light/profile-list.mcssView
@@ -32,12 +32,8 @@
3232 height: 12px
3333 content: "<circle cx='6' stroke='#888' fill='none' cy='6' r='5' /> <circle cx='6' cy='6' r='3' fill='#888'/>"
3434 }
3535
36- :hover {
37- background-color: rgba(255, 255, 255, 0.4);
38- }
39-
4036 div.avatar {
4137 img {
4238 width: 40px
4339 height: 40px
@@ -70,9 +66,44 @@
7066 -pending {
7167 opacity: 1
7268 }
7369 width: 20px
74- flex: 1
70 + flex: 1
7571 }
7672 }
73 +
74 + div.controls {
75 + opacity: 0
76 + position: absolute
77 + right: 7px
78 + top: 0
79 + bottom: 0
80 + display: flex;
81 + justify-content: center;
82 + flex-direction: column;
83 + width: 15px;
84 + transition: opacity 0.2s
85 + a.disconnect {
86 + color: white;
87 + border-radius: 10px;
88 + height: 16px;
89 + width: 16px;
90 + background-color: #777
91 + text-align: center
92 + vertical-align: middle
93 + font-size: 14px;
94 + overflow: hidden;
95 + :hover {
96 + text-decoration: none
97 + background-color: #F77
98 + }
99 + }
100 + }
101 +
102 + :hover {
103 + background-color: rgba(255, 255, 255, 0.4);
104 + div.controls {
105 + opacity: 1
106 + }
107 + }
77108 }
78109 }

Built with git-ssb-web