git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 39e2313627e48eb9e37b220156a07c43f51d7adc

also include yourId and theirId in assigned value filtering

Matt McKegg committed on 10/14/2017, 5:04:12 AM
Parent: 9cb6a53289e695dec730708c30a8a917e6269c7d

Files changed

modules/page/html/render/profile.jschanged
modules/page/html/render/profile.jsView
@@ -77,10 +77,10 @@
7777 var youBlock = computed(blockers, function (blockers) {
7878 return blockers.includes(yourId)
7979 })
8080
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)
8383
8484 var namePicker = h('div', {className: 'Picker'}, [
8585 map(dictToCollection(names), (item) => {
8686 var isSelf = computed(item.value, (ids) => ids.includes(id))
@@ -219,22 +219,8 @@
219219
220220 container.pendingUpdates = feedView.pendingUpdates
221221 container.reload = feedView.reload
222222 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- }
237223 })
238224
239225 function renderContactBlock (title, profiles, yourFollows) {
240226 profiles = api.profile.obs.rank(profiles)
@@ -349,4 +335,22 @@
349335 return (prefix ? (prefix + '\n') : '') + names.map((n) => `- ${n}`).join('\n')
350336 })
351337 }
352338 }
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