Commit 39e2313627e48eb9e37b220156a07c43f51d7adc
also include yourId and theirId in assigned value filtering
Matt McKegg committed on 10/14/2017, 5:04:12 AMParent: 9cb6a53289e695dec730708c30a8a917e6269c7d
Files changed
modules/page/html/render/profile.js | changed |
modules/page/html/render/profile.js | ||
---|---|---|
@@ -77,10 +77,10 @@ | ||
77 | 77 | var youBlock = computed(blockers, function (blockers) { |
78 | 78 | return blockers.includes(yourId) |
79 | 79 | }) |
80 | 80 | |
81 | - var names = computed([api.about.obs.names(id), yourFollows, rawFollowing], onlyEndorsed) | |
82 | - var images = computed([api.about.obs.images(id), yourFollows, rawFollowing], onlyEndorsed) | |
81 | + var names = computed([api.about.obs.names(id), yourFollows, rawFollowing, yourId, id], filterByValues) | |
82 | + var images = computed([api.about.obs.images(id), yourFollows, rawFollowing, yourId, id], filterByValues) | |
83 | 83 | |
84 | 84 | var namePicker = h('div', {className: 'Picker'}, [ |
85 | 85 | map(dictToCollection(names), (item) => { |
86 | 86 | var isSelf = computed(item.value, (ids) => ids.includes(id)) |
@@ -219,22 +219,8 @@ | ||
219 | 219 | |
220 | 220 | container.pendingUpdates = feedView.pendingUpdates |
221 | 221 | container.reload = feedView.reload |
222 | 222 | return container |
223 | - | |
224 | - // scoped | |
225 | - | |
226 | - function onlyEndorsed (values, yourFollows, theirFollows) { | |
227 | - return Object.keys(values).reduce((result, key) => { | |
228 | - var ids = values[key].filter(id => { | |
229 | - return yourFollows.includes(id) || theirFollows.includes(id) | |
230 | - }) | |
231 | - if (ids.length) { | |
232 | - result[key] = ids | |
233 | - } | |
234 | - return result | |
235 | - }, {}) | |
236 | - } | |
237 | 223 | }) |
238 | 224 | |
239 | 225 | function renderContactBlock (title, profiles, yourFollows) { |
240 | 226 | profiles = api.profile.obs.rank(profiles) |
@@ -349,4 +335,22 @@ | ||
349 | 335 | return (prefix ? (prefix + '\n') : '') + names.map((n) => `- ${n}`).join('\n') |
350 | 336 | }) |
351 | 337 | } |
352 | 338 | } |
339 | + | |
340 | +function filterByValues (attributes, ...matchValues) { | |
341 | + return Object.keys(attributes).reduce((result, key) => { | |
342 | + var values = attributes[key].filter(value => { | |
343 | + return matchValues.some(matchValue => { | |
344 | + if (Array.isArray(matchValue)) { | |
345 | + return matchValue.includes(value) | |
346 | + } else { | |
347 | + return matchValue === value | |
348 | + } | |
349 | + }) | |
350 | + }) | |
351 | + if (values.length) { | |
352 | + result[key] = values | |
353 | + } | |
354 | + return result | |
355 | + }, {}) | |
356 | +} |
Built with git-ssb-web