git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 5cd9c24978c2e556596ba08fa0cc17a1d2ba0dc8

remove profile.obs.names, and split into appropriate locations

Matt McKegg committed on 2/16/2017, 5:24:13 AM
Parent: 6564ad1491e92cadd2cd0c9f59444b6f8c8cdaf2

Files changed

modules/feed/html/rollup.jschanged
modules/profile/obs/names.jsdeleted
plugs/message/html/meta/likes.jschanged
modules/feed/html/rollup.jsView
@@ -3,8 +3,9 @@
33 var computed = require('mutant/computed')
44 var h = require('mutant/h')
55 var MutantArray = require('mutant/array')
66 var Abortable = require('pull-abortable')
7+var map = require('mutant/map')
78 var pull = require('pull-stream')
89 var nest = require('depnest')
910
1011 var onceTrue = require('mutant/once-true')
@@ -16,16 +17,16 @@
1617 link: 'first'
1718 },
1819 'sbot.async.get': 'first',
1920 'keys.sync.id': 'first',
21+ 'about.obs.name': 'first',
2022 feed: {
2123 'html.rollup': 'first',
2224 'pull.summary': 'first'
2325 },
2426 profile: {
2527 'html.person': 'first',
26- 'html.manyPeople': 'first',
27- 'obs.names': 'first'
28+ 'html.manyPeople': 'first'
2829 }
2930 })
3031
3132 exports.gives = nest({
@@ -176,15 +177,15 @@
176177 var renderedMessage = item.message ? api.message.html.render(item.message, {inContext: true}) : null
177178 if (renderedMessage) {
178179 if (item.lastUpdateType === 'reply' && item.repliesFrom.size) {
179180 meta = h('div.meta', {
180- title: api.profile.obs.names(item.repliesFrom)
181+ title: names(item.repliesFrom)
181182 }, [
182183 api.profile.html.manyPeople(item.repliesFrom), ' replied'
183184 ])
184185 } else if (item.lastUpdateType === 'dig' && item.digs.size) {
185186 meta = h('div.meta', {
186- title: api.profile.obs.names(item.digs)
187+ title: names(item.digs)
187188 }, [
188189 api.profile.html.manyPeople(item.digs), ' dug this message'
189190 ])
190191 }
@@ -201,15 +202,15 @@
201202 ])
202203 } else {
203204 if (item.lastUpdateType === 'reply' && item.repliesFrom.size) {
204205 meta = h('div.meta', {
205- title: api.profile.obs.names(item.repliesFrom)
206+ title: names(item.repliesFrom)
206207 }, [
207208 api.profile.html.manyPeople(item.repliesFrom), ' replied to ', api.message.html.link(item.messageId)
208209 ])
209210 } else if (item.lastUpdateType === 'dig' && item.digs.size) {
210211 meta = h('div.meta', {
211- title: api.profile.obs.names(item.digs)
212+ title: names(item.digs)
212213 }, [
213214 api.profile.html.manyPeople(item.digs), ' dug ', api.message.html.link(item.messageId)
214215 ])
215216 }
@@ -222,14 +223,19 @@
222223 }
223224 } else if (item.type === 'follow') {
224225 return h('div', {className: 'FeedEvent -follow'}, [
225226 h('div.meta', {
226- title: api.profile.obs.names(item.contacts)
227+ title: names(item.contacts)
227228 }, [
228229 api.profile.html.person(item.id), ' followed ', api.profile.html.manyPeople(item.contacts)
229230 ])
230231 ])
231232 }
232233
233234 return h('div')
234235 }
236+
237+ function names (ids) {
238+ var items = map(ids, api.about.obs.name)
239+ return computed([items], (names) => names.map((n) => `- ${n}`).join('\n'))
240+ }
235241 }
modules/profile/obs/names.jsView
@@ -1,24 +1,0 @@
1-var nest = require('depnest')
2-var computed = require('mutant/computed')
3-
4-exports.needs = nest({
5- 'about.obs.name': 'first'
6-})
7-
8-exports.gives = nest({
9- 'profile.obs': [ 'names' ]
10-})
11-
12-exports.create = function (api) {
13- return nest({
14- 'profile.obs': { names }
15- })
16-
17- function names (ids) {
18- return computed(Array.from(ids).map(api.about.obs.name), join) || ''
19- }
20-}
21-
22-function join (...args) {
23- return args.join('\n')
24-}
plugs/message/html/meta/likes.jsView
@@ -1,10 +1,10 @@
11 var nest = require('depnest')
2-var { h, computed } = require('mutant')
2+var { h, computed, map } = require('mutant')
33 exports.gives = nest('message.html.meta')
44 exports.needs = nest({
55 'message.obs.likes': 'first',
6- 'profile.obs.names': 'first'
6+ 'about.obs.name': 'first'
77 })
88
99 exports.create = function (api) {
1010 return nest('message.html.meta', function likes (msg) {
@@ -13,9 +13,16 @@
1313
1414 function likeCount (likes) {
1515 if (likes.length) {
1616 return [' ', h('span.likes', {
17- title: api.profile.obs.names(likes)
17+ title: names(likes)
1818 }, ['+', h('strong', `${likes.length}`)])]
1919 }
2020 }
21+
22+ function names (ids) {
23+ var items = map(ids, api.about.obs.name)
24+ return computed([items], (names) => {
25+ return 'Liked by\n' + names.map((n) => `- ${n}`).join('\n')
26+ })
27+ }
2128 }

Built with git-ssb-web