Commit 0058b6aac60914bb37a401eab564b4b2418aa35f
first pass at blocking interface (temporarily disabled for patchcore refactor)
mix irving committed on 9/15/2017, 2:44:02 AMParent: 281a3bcf874278b04675432a0655c81ceba5f569
Files changed
background-process.js | changed |
contact/html/relationships.js | changed |
contact/html/relationships.mcss | changed |
main.js | changed |
message/html/compose.js | changed |
message/html/render/follow.js | deleted |
message/html/render/contact.js | added |
background-process.js | ||
---|---|---|
@@ -16,9 +16,9 @@ | ||
16 | 16 … | .use(require('scuttlebot/plugins/local')) |
17 | 17 … | .use(require('scuttlebot/plugins/logging')) |
18 | 18 … | .use(require('ssb-query')) |
19 | 19 … | .use(require('ssb-about')) |
20 | - .use(require('ssb-contacts')) | |
20 … | + // .use(require('ssb-contacts')) | |
21 | 21 … | .use(require('ssb-fulltext')) |
22 | 22 … | // .use(require('ssb-ebt')) |
23 | 23 … | .use(require('ssb-ws')) |
24 | 24 … |
contact/html/relationships.js | ||
---|---|---|
@@ -3,22 +3,17 @@ | ||
3 | 3 … | |
4 | 4 … | exports.gives = nest('contact.html.relationships') |
5 | 5 … | |
6 | 6 … | 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', | |
21 | 16 … | 'keys.sync.id': 'first' |
22 | 17 … | }) |
23 | 18 … | |
24 | 19 … | exports.create = function (api) { |
@@ -30,9 +25,9 @@ | ||
30 | 25 … | var rawFollowing = api.contact.obs.following(id) |
31 | 26 … | var rawFollowers = api.contact.obs.followers(id) |
32 | 27 … | |
33 | 28 … | var friends = computed([rawFollowing, rawFollowers], (following, followers) => { |
34 | - return [...following].filter(follow => followers.has(follow)) | |
29 … | + return [...following].filter(follow => followers.includes(follow)) | |
35 | 30 … | }) |
36 | 31 … | var following = computed([rawFollowing, friends], (following, friends) => { |
37 | 32 … | return [...following].filter(follow => !friends.includes(follow)) |
38 | 33 … | }) |
@@ -41,10 +36,10 @@ | ||
41 | 36 … | }) |
42 | 37 … | |
43 | 38 … | var myId = api.keys.sync.id() |
44 | 39 … | 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)) | |
47 | 42 … | |
48 | 43 … | var relationshipStatus = computed([IFollowThem, theyFollowMe], (IFollowThem, theyFollowMe) => { |
49 | 44 … | return IFollowThem && theyFollowMe ? '- you are friends' |
50 | 45 … | : IFollowThem ? '- you follow them' |
@@ -58,23 +53,37 @@ | ||
58 | 53 … | api.about.html.image(id) |
59 | 54 … | ) |
60 | 55 … | } |
61 | 56 … | |
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 … | + | |
62 | 61 … | return h('Relationships', [ |
63 | 62 … | h('header', 'Relationships'), |
64 | 63 … | when(id !== myId, |
65 | 64 … | h('div.your-status', [ |
66 | 65 … | h('header', 'Your status'), |
67 | - h('section.action', [ | |
66 … | + h('section -friendship', [ | |
68 | 67 … | when(ImFollowing.sync, |
69 | 68 … | 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') | |
72 | 71 … | ), |
73 | 72 … | h('button', { disabled: 'disabled' }, 'Loading...') |
74 | - ) | |
73 … | + ), | |
74 … | + when(ImFollowing.sync, h('div.relationship-status', relationshipStatus)), | |
75 | 75 … | ]), |
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 … | + ]) | |
77 | 86 … | ]) |
78 | 87 … | ), |
79 | 88 … | h('div.friends', [ |
80 | 89 … | h('header', 'Friends'), |
contact/html/relationships.mcss | ||
---|---|---|
@@ -34,15 +34,26 @@ | ||
34 | 34 … | align-items: center |
35 | 35 … | |
36 | 36 … | margin: 0 |
37 | 37 … | |
38 | - section.action { | |
39 | - button { margin-left: 0 } | |
38 … | + display: flex | |
40 | 39 … | |
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 … | + } | |
41 | 54 … | } |
42 | - section.status { | |
43 | - | |
44 | - } | |
55 … | + | |
45 | 56 … | } |
46 | 57 … | |
47 | 58 … | div.friends { |
48 | 59 … | section a { |
main.js | ||
---|---|---|
@@ -18,21 +18,23 @@ | ||
18 | 18 … | styles: bulk(__dirname, [ 'styles/**/*.js' ]), |
19 | 19 … | |
20 | 20 … | config: require('./config'), // shouldn't be in here ? |
21 | 21 … | contextMenu: require('patch-context'), |
22 … | + inbox: require('patch-inbox'), | |
23 … | + history: require('patch-history') | |
22 | 24 … | } |
23 | 25 … | } |
24 | 26 … | |
25 | 27 … | |
26 | 28 … | // from more specialized to more general |
27 | 29 … | const sockets = combine( |
28 | 30 … | //require('ssb-horcrux'), |
29 | 31 … | //require('patch-hub'), |
32 … | + | |
30 | 33 … | require('ssb-chess'), |
31 | 34 … | 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 | |
35 | 37 … | patchbay, |
36 | 38 … | require('patchcore') |
37 | 39 … | ) |
38 | 40 … |
message/html/compose.js | ||
---|---|---|
@@ -73,9 +73,8 @@ | ||
73 | 73 … | h('div.close', { 'ev-click': () => warningMessage.set(null) }, 'x') |
74 | 74 … | ] |
75 | 75 … | ) |
76 | 76 … | var fileInput = api.blob.html.input(file => { |
77 | - | |
78 | 77 … | const megabytes = file.size / 1024 / 1024 |
79 | 78 … | if (megabytes >= 5) { |
80 | 79 … | const rounded = Math.floor(megabytes*100)/100 |
81 | 80 … | warningMessage.set([ |
message/html/render/follow.js | ||
---|---|---|
@@ -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.js | ||
---|---|---|
@@ -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