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.js | changed |
modules/page/html/render/profile.js | ||
---|---|---|
@@ -25,10 +25,13 @@ | ||
25 | 25 | 'profile.sheet.edit': 'first', |
26 | 26 | 'app.navigate': 'first', |
27 | 27 | 'contact.obs': { |
28 | 28 | followers: 'first', |
29 | - following: 'first' | |
29 | + following: 'first', | |
30 | + blockers: 'first' | |
30 | 31 | }, |
32 | + 'contact.async.block': 'first', | |
33 | + 'contact.async.unblock': 'first', | |
31 | 34 | 'intl.sync.i18n': 'first', |
32 | 35 | }) |
33 | 36 | exports.gives = nest('page.html.render') |
34 | 37 | |
@@ -43,8 +46,9 @@ | ||
43 | 46 | var yourFollows = api.contact.obs.following(yourId) |
44 | 47 | var rawFollowers = api.contact.obs.followers(id) |
45 | 48 | var rawFollowing = api.contact.obs.following(id) |
46 | 49 | var friendsLoaded = computed([rawFollowers.sync, rawFollowing.sync], (...x) => x.every(Boolean)) |
50 | + var { block, unblock } = api.contact.async | |
47 | 51 | |
48 | 52 | var friends = computed([rawFollowing, rawFollowers], (following, followers) => { |
49 | 53 | return Array.from(following).filter(follow => followers.includes(follow)) |
50 | 54 | }) |
@@ -68,8 +72,13 @@ | ||
68 | 72 | var youFollow = computed([yourFollows], function (youFollow) { |
69 | 73 | return youFollow.includes(id) |
70 | 74 | }) |
71 | 75 | |
76 | + var blockers = api.contact.obs.blockers(id) | |
77 | + var ImBlockingThem = computed(blockers, function(blockers) { | |
78 | + return blockers.includes(yourId) | |
79 | + }) | |
80 | + | |
72 | 81 | var names = api.about.obs.names(id) |
73 | 82 | var images = api.about.obs.images(id) |
74 | 83 | |
75 | 84 | var namePicker = h('div', {className: 'Picker'}, [ |
@@ -152,10 +161,22 @@ | ||
152 | 161 | h('a.ToggleButton.-subscribe', { |
153 | 162 | 'href': '#', |
154 | 163 | 'ev-click': send(follow, id) |
155 | 164 | }, 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')), | |
156 | 177 | ) |
157 | - ]) | |
178 | + ]), | |
158 | 179 | ]) |
159 | 180 | ]), |
160 | 181 | h('section -description', [ |
161 | 182 | computed(description, (text) => { |
Built with git-ssb-web