git ssb

10+

Matt McKegg / patchwork



Commit 8f4b44fd5c96edb542eb7ebe86e16d6807a5abc5

Merge branch 'gmarcos87-block-users'

Matt McKegg committed on 10/14/2017, 2:22:13 AM
Parent: 14f1ed9474297056ede54cf5ac32ab68c782d79d
Parent: ef7568bb81ad98245bc972115cc42be6521a3f63

Files changed

locales/en.jsonchanged
locales/es.jsonchanged
modules/page/html/render/profile.jschanged
package.jsonchanged
plugs/message/html/render/following.jschanged
styles/dark/toggle-button.mcsschanged
styles/light/profile-header.mcsschanged
styles/light/toggle-button.mcsschanged
locales/en.jsonView
@@ -137,9 +137,16 @@
137137 "New Message": "New Message",
138138 "unsubscribed from ": "unsubscribed from ",
139139 "en": "en",
140140 "on ": "on ",
141+ "de": "German",
141142 "Private Message": "Private Message",
142143 "Send Private Message": "Send Private Message",
143144 "Publish Privately": "Publish Privately",
144- "de": "German"
145+ "Unblock": "Unblock",
146+ "Block": "Block",
147+ "Click to unblock": "Click to unblock",
148+ "Blocked": "Blocked",
149+ "pt": "pt",
150+ "blocked ": "blocked ",
151+ "unblocked ": "unblocked "
145152 }
locales/es.jsonView
@@ -1,6 +1,6 @@
11 {
2- "$name": "el español",
2+ "$name": "Español",
33 "Patchwork": "Patchwork",
44 "Public": "Público",
55 "Private": "Privado",
66 "Write a public message": "Escribe un mensaje públio",
@@ -135,6 +135,13 @@
135135 "second": "segundos",
136136 "unsubscribed from ": "desuscrito de ",
137137 "en": "en",
138138 "es": "es",
139- "ki": "ki"
139+ "ki": "ki",
140+ "Publish Privately": "Publicar en privado",
141+ "Send Private Message": "Enviar mensaje privado",
142+ "de": "de",
143+ "pt": "pt",
144+ "on ": "on ",
145+ "Unblock": "Desbloquear",
146+ "Block": "Bloquear"
140147 }
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 youBlock = 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'}, [
@@ -142,19 +151,32 @@
142151 h('div.meta', [
143152 when(id === yourId, [
144153 h('button', {'ev-click': api.profile.sheet.edit}, i18n('Edit Your Profile'))
145154 ], [
146- when(youFollow,
147- h('a.ToggleButton.-unsubscribe', {
155+ when(youBlock, [
156+ h('a.ToggleButton.-unblocking', {
148157 'href': '#',
149- 'title': i18n('Click to unfollow'),
150- 'ev-click': send(unfollow, id)
151- }, when(isFriends, i18n('Friends'), i18n('Following'))),
152- h('a.ToggleButton.-subscribe', {
158+ 'title': i18n('Click to unblock'),
159+ 'ev-click': () => unblock(id, console.log)
160+ }, i18n('Blocked'))
161+ ], [
162+ when(youFollow,
163+ h('a.ToggleButton.-unsubscribe', {
164+ 'href': '#',
165+ 'title': i18n('Click to unfollow'),
166+ 'ev-click': send(unfollow, id)
167+ }, when(isFriends, i18n('Friends'), i18n('Following'))),
168+ h('a.ToggleButton.-subscribe', {
169+ 'href': '#',
170+ 'ev-click': send(follow, id)
171+ }, when(followsYou, i18n('Follow Back'), i18n('Follow')))
172+ ),
173+ h('a.ToggleButton.-blocking', {
153174 'href': '#',
154- 'ev-click': send(follow, id)
155- }, when(followsYou, i18n('Follow Back'), i18n('Follow')))
156- )
175+ 'title': i18n('Block'),
176+ 'ev-click': () => block(id, console.log)
177+ }, i18n('Block'))
178+ ])
157179 ])
158180 ])
159181 ]),
160182 h('section -description', [
@@ -170,9 +192,10 @@
170192
171193 var feedView = api.feed.html.rollup(api.feed.pull.profile(id), {
172194 prepend,
173195 displayFilter: (msg) => msg.value.author === id,
174- bumpFilter: (msg) => msg.value.author === id,
196+ rootFilter: (msg) => !youBlock(),
197+ bumpFilter: (msg) => msg.value.author === id
175198 })
176199
177200 var container = h('div', {className: 'SplitView'}, [
178201 h('div.main', [
@@ -190,8 +213,11 @@
190213 )
191214 ])
192215 ])
193216
217+ // refresh feed (to hide all posts) when blocked
218+ youBlock(feedView.reload)
219+
194220 container.pendingUpdates = feedView.pendingUpdates
195221 container.reload = feedView.reload
196222 return container
197223 })
package.jsonView
@@ -27,8 +27,9 @@
2727 "fix-path": "^2.1.0",
2828 "flatpickr": "^3.0.5-1",
2929 "flumeview-level": "^2.0.3",
3030 "hashlru": "^2.2.0",
31+ "human-time": "0.0.1",
3132 "i18n": "^0.8.3",
3233 "insert-css": "~2.0.0",
3334 "level": "~1.7.0",
3435 "lrucache": "^1.0.2",
@@ -38,9 +39,9 @@
3839 "mutant": "^3.21.2",
3940 "mutant-pull-reduce": "^1.1.0",
4041 "obv": "0.0.1",
4142 "patch-settings": "^1.0.1",
42- "patchcore": "~1.12.1",
43+ "patchcore": "~1.13.0",
4344 "pull-abortable": "^4.1.0",
4445 "pull-defer": "^0.2.2",
4546 "pull-file": "~1.0.0",
4647 "pull-identify-filetype": "^1.1.0",
plugs/message/html/render/following.jsView
@@ -18,9 +18,9 @@
1818 const i18n = api.intl.sync.i18n
1919 return nest('message.html.render', function renderMessage (msg, opts) {
2020 if (msg.value.content.type !== 'contact') return
2121 if (!ref.isFeed(msg.value.content.contact)) return
22- if (typeof msg.value.content.following !== 'boolean') return
22+ if (typeof msg.value.content.following !== 'boolean' && typeof msg.value.content.blocking !== 'boolean') return
2323
2424 var element = api.message.html.layout(msg, extend({
2525 miniContent: messageContent(msg),
2626 layout: 'mini'
@@ -30,10 +30,19 @@
3030 })
3131
3232 function messageContent (msg) {
3333 var following = msg.value.content.following
34- return [
35- following ? i18n('followed ') : i18n('unfollowed '),
36- api.profile.html.person(msg.value.content.contact)
37- ]
34+ var blocking = msg.value.content.blocking
35+
36+ if (typeof blocking === 'boolean') {
37+ return [
38+ blocking ? i18n('blocked ') : i18n('unblocked '),
39+ api.profile.html.person(msg.value.content.contact)
40+ ]
41+ } else {
42+ return [
43+ following ? i18n('followed ') : i18n('unfollowed '),
44+ api.profile.html.person(msg.value.content.contact)
45+ ]
46+ }
3847 }
3948 }
styles/dark/toggle-button.mcssView
@@ -31,8 +31,20 @@
3131 background-image: svg(subscribed-hover)
3232 }
3333 }
3434
35+ -blocking {
36+ margin-left: 5px
37+ border: 0px
38+ }
39+
40+ -unblocking {
41+ margin-left: 5px
42+ background-color: rgb(212, 112, 112)
43+ color: #ffffff
44+ border: 0px
45+ }
46+
3547 -disabled {
3648 cursor: default
3749 opacity: 0.4 !important
3850 text-decoration: none !important
styles/light/profile-header.mcssView
@@ -22,8 +22,14 @@
2222 display: flex
2323 h1 {
2424 flex: 1
2525 }
26+ div.meta {
27+ a {
28+ margin-left: 5px
29+ display: inline-block
30+ }
31+ }
2632 }
2733 section {
2834 -description {
2935 font-size: 120%
styles/light/toggle-button.mcssView
@@ -22,8 +22,13 @@
2222 background-image: svg(subscribed)
2323 padding-right: 25px
2424 }
2525
26+ -unblocking {
27+ background-color: #deb250
28+ border-color: #ad7904
29+ }
30+
2631 -disabled {
2732 cursor: default
2833 opacity: 0.4 !important
2934 text-decoration: none !important

Built with git-ssb-web