git ssb

16+

Dominic / patchbay



Commit 0058b6aac60914bb37a401eab564b4b2418aa35f

first pass at blocking interface (temporarily disabled for patchcore refactor)

mix irving committed on 9/15/2017, 2:44:02 AM
Parent: 281a3bcf874278b04675432a0655c81ceba5f569

Files changed

background-process.jschanged
contact/html/relationships.jschanged
contact/html/relationships.mcsschanged
main.jschanged
message/html/compose.jschanged
message/html/render/follow.jsdeleted
message/html/render/contact.jsadded
background-process.jsView
@@ -16,9 +16,9 @@
1616 .use(require('scuttlebot/plugins/local'))
1717 .use(require('scuttlebot/plugins/logging'))
1818 .use(require('ssb-query'))
1919 .use(require('ssb-about'))
20- .use(require('ssb-contacts'))
20 + // .use(require('ssb-contacts'))
2121 .use(require('ssb-fulltext'))
2222 // .use(require('ssb-ebt'))
2323 .use(require('ssb-ws'))
2424
contact/html/relationships.jsView
@@ -3,22 +3,17 @@
33
44 exports.gives = nest('contact.html.relationships')
55
66 exports.needs = nest({
7- about: {
8- 'html.image': 'first',
9- 'obs.name': 'first'
10- },
11- contact: {
12- async: {
13- follow: 'first',
14- unfollow: 'first'
15- },
16- obs: {
17- followers: 'first',
18- following: 'first'
19- }
20- },
7 + 'about.html.image': 'first',
8 + 'about.obs.name': 'first',
9 + 'contact.async.follow': 'first',
10 + 'contact.async.unfollow': 'first',
11 + 'contact.async.block': 'first',
12 + 'contact.async.unblock': 'first',
13 + 'contact.obs.followers': 'first',
14 + 'contact.obs.following': 'first',
15 + // 'contact.obs.blockers': 'first',
2116 'keys.sync.id': 'first'
2217 })
2318
2419 exports.create = function (api) {
@@ -30,9 +25,9 @@
3025 var rawFollowing = api.contact.obs.following(id)
3126 var rawFollowers = api.contact.obs.followers(id)
3227
3328 var friends = computed([rawFollowing, rawFollowers], (following, followers) => {
34- return [...following].filter(follow => followers.has(follow))
29 + return [...following].filter(follow => followers.includes(follow))
3530 })
3631 var following = computed([rawFollowing, friends], (following, friends) => {
3732 return [...following].filter(follow => !friends.includes(follow))
3833 })
@@ -41,10 +36,10 @@
4136 })
4237
4338 var myId = api.keys.sync.id()
4439 var ImFollowing = api.contact.obs.following(myId)
45- var IFollowThem = computed([ImFollowing], ImFollowing => ImFollowing.has(id))
46- var theyFollowMe = computed([rawFollowing], following => following.has(myId))
40 + var IFollowThem = computed([ImFollowing], ImFollowing => ImFollowing.includes(id))
41 + var theyFollowMe = computed([rawFollowing], following => following.includes(myId))
4742
4843 var relationshipStatus = computed([IFollowThem, theyFollowMe], (IFollowThem, theyFollowMe) => {
4944 return IFollowThem && theyFollowMe ? '- you are friends'
5045 : IFollowThem ? '- you follow them'
@@ -58,23 +53,37 @@
5853 api.about.html.image(id)
5954 )
6055 }
6156
57 + const { unfollow, follow, block, unblock } = api.contact.async
58 + // const blockedBy = api.contact.obs.blockers(id)
59 + // const ImBlockingThem = computed(blockedBy, blockers => blockers.has(myId))
60 +
6261 return h('Relationships', [
6362 h('header', 'Relationships'),
6463 when(id !== myId,
6564 h('div.your-status', [
6665 h('header', 'Your status'),
67- h('section.action', [
66 + h('section -friendship', [
6867 when(ImFollowing.sync,
6968 when(IFollowThem,
70- h('button', { 'ev-click': () => api.contact.async.unfollow(id) }, 'Unfollow'),
71- h('button', { 'ev-click': () => api.contact.async.follow(id) }, 'Follow')
69 + h('button', { 'ev-click': () => unfollow(id) }, 'Unfollow'),
70 + h('button', { 'ev-click': () => follow(id) }, 'Follow')
7271 ),
7372 h('button', { disabled: 'disabled' }, 'Loading...')
74- )
73 + ),
74 + when(ImFollowing.sync, h('div.relationship-status', relationshipStatus)),
7575 ]),
76- when(ImFollowing.sync, h('section.status', relationshipStatus))
76 + h('section -blocking', [
77 + // when(ImBlockingThem,
78 + // h('button', { 'ev-click': () => unblock(id, console.log) }, 'unblock'),
79 + // h('button', { 'ev-click': () => block(id, console.log) }, 'BLOCK')
80 + // ),
81 + h('div.explainer', [
82 + "Blocking is a way to tell others that you don't want to communicate with a person ",
83 + "(you don't want to hear from them, and you don't want them to hear about you)."
84 + ])
85 + ])
7786 ])
7887 ),
7988 h('div.friends', [
8089 h('header', 'Friends'),
contact/html/relationships.mcssView
@@ -34,15 +34,26 @@
3434 align-items: center
3535
3636 margin: 0
3737
38- section.action {
39- button { margin-left: 0 }
38 + display: flex
4039
40 + section {
41 + button { margin: 0 }
42 +
43 + -friendship {
44 + display: flex
45 + div.relationship-status {
46 + margin: auto
47 + margin-left: .5rem
48 + }
49 +
50 + }
51 + -blocking {
52 + margin-left: 8rem
53 + }
4154 }
42- section.status {
43-
44- }
55 +
4556 }
4657
4758 div.friends {
4859 section a {
main.jsView
@@ -18,21 +18,23 @@
1818 styles: bulk(__dirname, [ 'styles/**/*.js' ]),
1919
2020 config: require('./config'), // shouldn't be in here ?
2121 contextMenu: require('patch-context'),
22 + inbox: require('patch-inbox'),
23 + history: require('patch-history')
2224 }
2325 }
2426
2527
2628 // from more specialized to more general
2729 const sockets = combine(
2830 //require('ssb-horcrux'),
2931 //require('patch-hub'),
32 +
3033 require('ssb-chess'),
3134 require('patchbay-gatherings'),
32- require('patch-inbox'),
33- require('patch-history'),
34- require('patch-settings'),
35 + // require('patch-network),
36 + require('patch-settings'), // might need to be in patchbay
3537 patchbay,
3638 require('patchcore')
3739 )
3840
message/html/compose.jsView
@@ -73,9 +73,8 @@
7373 h('div.close', { 'ev-click': () => warningMessage.set(null) }, 'x')
7474 ]
7575 )
7676 var fileInput = api.blob.html.input(file => {
77-
7877 const megabytes = file.size / 1024 / 1024
7978 if (megabytes >= 5) {
8079 const rounded = Math.floor(megabytes*100)/100
8180 warningMessage.set([
message/html/render/follow.jsView
@@ -1,37 +1,0 @@
1-const nest = require('depnest')
2-const extend = require('xtend')
3-const { isFeed } = require('ssb-ref')
4-
5-exports.gives = nest('message.html.render')
6-
7-exports.needs = nest({
8- 'about.html.link': 'first',
9- 'message.html': {
10- decorate: 'reduce',
11- layout: 'first'
12- }
13-})
14-
15-exports.create = function (api) {
16- return nest('message.html.render', follow)
17-
18- function follow (msg, opts) {
19- const { type, contact, following } = msg.value.content
20- if (type !== 'contact') return
21- if (!isFeed(contact)) return
22-
23- const element = api.message.html.layout(msg, extend({
24- content: renderContent({ contact, following }),
25- layout: 'mini'
26- }, opts))
27-
28- return api.message.html.decorate(element, { msg })
29- }
30-
31- function renderContent ({ contact, following }) {
32- return [
33- following ? 'followed ' : 'unfollowed ',
34- api.about.html.link(contact)
35- ]
36- }
37-}
message/html/render/contact.jsView
@@ -1,0 +1,43 @@
1 +const nest = require('depnest')
2 +const extend = require('xtend')
3 +const { isFeed } = require('ssb-ref')
4 +
5 +exports.gives = nest('message.html.render')
6 +
7 +exports.needs = nest({
8 + 'about.html.link': 'first',
9 + 'message.html': {
10 + decorate: 'reduce',
11 + layout: 'first'
12 + }
13 +})
14 +
15 +exports.create = function (api) {
16 + return nest('message.html.render', follow)
17 +
18 + function follow (msg, opts) {
19 + const { type, contact, following, blocking } = msg.value.content
20 + if (type !== 'contact') return
21 + if (!isFeed(contact)) return
22 +
23 + const element = api.message.html.layout(msg, extend({
24 + content: renderContent({ contact, following, blocking }),
25 + layout: 'mini'
26 + }, opts))
27 +
28 + return api.message.html.decorate(element, { msg })
29 + }
30 +
31 + function renderContent ({ contact, following, blocking }) {
32 + const name = api.about.html.link(contact)
33 +
34 + if (blocking != undefined) return [
35 + blocking ? 'blocked ' : 'unblocked ',
36 + name
37 + ]
38 + if (following != undefined) return [
39 + following ? 'followed ' : 'unfollowed ',
40 + name
41 + ]
42 + }
43 +}

Built with git-ssb-web