git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit fd85531cc70593cf1a26e65c7f4b8f3c2f435b95

Add feature to block users in profile

This implementation is the same functionality that Patchbay already has.
Marcos Gutierrez committed on 10/13/2017, 10:08:47 AM
Parent: 14f1ed9474297056ede54cf5ac32ab68c782d79d

Files changed

modules/page/html/render/profile.jschanged
modules/page/html/render/profile.jsView
@@ -25,10 +25,13 @@
2525 'profile.sheet.edit': 'first',
2626 'app.navigate': 'first',
2727 'contact.obs': {
2828 followers: 'first',
29- following: 'first'
29+ following: 'first',
30+ blockers: 'first'
3031 },
32+ 'contact.async.block': 'first',
33+ 'contact.async.unblock': 'first',
3134 'intl.sync.i18n': 'first',
3235 })
3336 exports.gives = nest('page.html.render')
3437
@@ -43,8 +46,9 @@
4346 var yourFollows = api.contact.obs.following(yourId)
4447 var rawFollowers = api.contact.obs.followers(id)
4548 var rawFollowing = api.contact.obs.following(id)
4649 var friendsLoaded = computed([rawFollowers.sync, rawFollowing.sync], (...x) => x.every(Boolean))
50+ var { block, unblock } = api.contact.async
4751
4852 var friends = computed([rawFollowing, rawFollowers], (following, followers) => {
4953 return Array.from(following).filter(follow => followers.includes(follow))
5054 })
@@ -68,8 +72,13 @@
6872 var youFollow = computed([yourFollows], function (youFollow) {
6973 return youFollow.includes(id)
7074 })
7175
76+ var blockers = api.contact.obs.blockers(id)
77+ var ImBlockingThem = computed(blockers, function(blockers) {
78+ return blockers.includes(yourId)
79+ })
80+
7281 var names = api.about.obs.names(id)
7382 var images = api.about.obs.images(id)
7483
7584 var namePicker = h('div', {className: 'Picker'}, [
@@ -152,10 +161,22 @@
152161 h('a.ToggleButton.-subscribe', {
153162 'href': '#',
154163 'ev-click': send(follow, id)
155164 }, when(followsYou, i18n('Follow Back'), i18n('Follow')))
165+ ),
166+ when(ImBlockingThem,
167+ h('a.ToggleButton.-unblocking', {
168+ 'href': '#',
169+ 'title': i18n('Unblock'),
170+ 'ev-click': () => unblock(id, console.log)
171+ }, i18n('Unblock')),
172+ h('a.ToggleButton.-blocking', {
173+ 'href': '#',
174+ 'title': i18n('Block'),
175+ 'ev-click': () => block(id, console.log)
176+ }, i18n('Block')),
156177 )
157- ])
178+ ]),
158179 ])
159180 ]),
160181 h('section -description', [
161182 computed(description, (text) => {

Built with git-ssb-web