Commit 8f4b44fd5c96edb542eb7ebe86e16d6807a5abc5
Merge branch 'gmarcos87-block-users'
Matt McKegg committed on 10/14/2017, 2:22:13 AMParent: 14f1ed9474297056ede54cf5ac32ab68c782d79d
Parent: ef7568bb81ad98245bc972115cc42be6521a3f63
Files changed
locales/en.json | changed |
locales/es.json | changed |
modules/page/html/render/profile.js | changed |
package.json | changed |
plugs/message/html/render/following.js | changed |
styles/dark/toggle-button.mcss | changed |
styles/light/profile-header.mcss | changed |
styles/light/toggle-button.mcss | changed |
locales/en.json | ||
---|---|---|
@@ -137,9 +137,16 @@ | ||
137 | 137 | "New Message": "New Message", |
138 | 138 | "unsubscribed from ": "unsubscribed from ", |
139 | 139 | "en": "en", |
140 | 140 | "on ": "on ", |
141 | + "de": "German", | |
141 | 142 | "Private Message": "Private Message", |
142 | 143 | "Send Private Message": "Send Private Message", |
143 | 144 | "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 " | |
145 | 152 | } |
locales/es.json | ||
---|---|---|
@@ -1,6 +1,6 @@ | ||
1 | 1 | { |
2 | - "$name": "el español", | |
2 | + "$name": "Español", | |
3 | 3 | "Patchwork": "Patchwork", |
4 | 4 | "Public": "Público", |
5 | 5 | "Private": "Privado", |
6 | 6 | "Write a public message": "Escribe un mensaje públio", |
@@ -135,6 +135,13 @@ | ||
135 | 135 | "second": "segundos", |
136 | 136 | "unsubscribed from ": "desuscrito de ", |
137 | 137 | "en": "en", |
138 | 138 | "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" | |
140 | 147 | } |
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 youBlock = 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'}, [ |
@@ -142,19 +151,32 @@ | ||
142 | 151 | h('div.meta', [ |
143 | 152 | when(id === yourId, [ |
144 | 153 | h('button', {'ev-click': api.profile.sheet.edit}, i18n('Edit Your Profile')) |
145 | 154 | ], [ |
146 | - when(youFollow, | |
147 | - h('a.ToggleButton.-unsubscribe', { | |
155 | + when(youBlock, [ | |
156 | + h('a.ToggleButton.-unblocking', { | |
148 | 157 | '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', { | |
153 | 174 | '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 | + ]) | |
157 | 179 | ]) |
158 | 180 | ]) |
159 | 181 | ]), |
160 | 182 | h('section -description', [ |
@@ -170,9 +192,10 @@ | ||
170 | 192 | |
171 | 193 | var feedView = api.feed.html.rollup(api.feed.pull.profile(id), { |
172 | 194 | prepend, |
173 | 195 | displayFilter: (msg) => msg.value.author === id, |
174 | - bumpFilter: (msg) => msg.value.author === id, | |
196 | + rootFilter: (msg) => !youBlock(), | |
197 | + bumpFilter: (msg) => msg.value.author === id | |
175 | 198 | }) |
176 | 199 | |
177 | 200 | var container = h('div', {className: 'SplitView'}, [ |
178 | 201 | h('div.main', [ |
@@ -190,8 +213,11 @@ | ||
190 | 213 | ) |
191 | 214 | ]) |
192 | 215 | ]) |
193 | 216 | |
217 | + // refresh feed (to hide all posts) when blocked | |
218 | + youBlock(feedView.reload) | |
219 | + | |
194 | 220 | container.pendingUpdates = feedView.pendingUpdates |
195 | 221 | container.reload = feedView.reload |
196 | 222 | return container |
197 | 223 | }) |
package.json | ||
---|---|---|
@@ -27,8 +27,9 @@ | ||
27 | 27 | "fix-path": "^2.1.0", |
28 | 28 | "flatpickr": "^3.0.5-1", |
29 | 29 | "flumeview-level": "^2.0.3", |
30 | 30 | "hashlru": "^2.2.0", |
31 | + "human-time": "0.0.1", | |
31 | 32 | "i18n": "^0.8.3", |
32 | 33 | "insert-css": "~2.0.0", |
33 | 34 | "level": "~1.7.0", |
34 | 35 | "lrucache": "^1.0.2", |
@@ -38,9 +39,9 @@ | ||
38 | 39 | "mutant": "^3.21.2", |
39 | 40 | "mutant-pull-reduce": "^1.1.0", |
40 | 41 | "obv": "0.0.1", |
41 | 42 | "patch-settings": "^1.0.1", |
42 | - "patchcore": "~1.12.1", | |
43 | + "patchcore": "~1.13.0", | |
43 | 44 | "pull-abortable": "^4.1.0", |
44 | 45 | "pull-defer": "^0.2.2", |
45 | 46 | "pull-file": "~1.0.0", |
46 | 47 | "pull-identify-filetype": "^1.1.0", |
plugs/message/html/render/following.js | ||
---|---|---|
@@ -18,9 +18,9 @@ | ||
18 | 18 | const i18n = api.intl.sync.i18n |
19 | 19 | return nest('message.html.render', function renderMessage (msg, opts) { |
20 | 20 | if (msg.value.content.type !== 'contact') return |
21 | 21 | 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 | |
23 | 23 | |
24 | 24 | var element = api.message.html.layout(msg, extend({ |
25 | 25 | miniContent: messageContent(msg), |
26 | 26 | layout: 'mini' |
@@ -30,10 +30,19 @@ | ||
30 | 30 | }) |
31 | 31 | |
32 | 32 | function messageContent (msg) { |
33 | 33 | 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 | + } | |
38 | 47 | } |
39 | 48 | } |
styles/dark/toggle-button.mcss | ||
---|---|---|
@@ -31,8 +31,20 @@ | ||
31 | 31 | background-image: svg(subscribed-hover) |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
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 | + | |
35 | 47 | -disabled { |
36 | 48 | cursor: default |
37 | 49 | opacity: 0.4 !important |
38 | 50 | text-decoration: none !important |
styles/light/profile-header.mcss | ||
---|---|---|
@@ -22,8 +22,14 @@ | ||
22 | 22 | display: flex |
23 | 23 | h1 { |
24 | 24 | flex: 1 |
25 | 25 | } |
26 | + div.meta { | |
27 | + a { | |
28 | + margin-left: 5px | |
29 | + display: inline-block | |
30 | + } | |
31 | + } | |
26 | 32 | } |
27 | 33 | section { |
28 | 34 | -description { |
29 | 35 | font-size: 120% |
styles/light/toggle-button.mcss | ||
---|---|---|
@@ -22,8 +22,13 @@ | ||
22 | 22 | background-image: svg(subscribed) |
23 | 23 | padding-right: 25px |
24 | 24 | } |
25 | 25 | |
26 | + -unblocking { | |
27 | + background-color: #deb250 | |
28 | + border-color: #ad7904 | |
29 | + } | |
30 | + | |
26 | 31 | -disabled { |
27 | 32 | cursor: default |
28 | 33 | opacity: 0.4 !important |
29 | 34 | text-decoration: none !important |
Built with git-ssb-web