git ssb

1+

ev / minbay



Tree: afe7de9580840925af61711b5ab0d6c57d1131a4

Files: afe7de9580840925af61711b5ab0d6c57d1131a4 / modules / avatar-profile.js

1776 bytesRaw
1var h = require('hyperscript')
2var pull = require('pull-stream')
3
4exports.needs = {
5 avatar_image_link: 'first',
6 avatar_action: 'map',
7 avatar_edit: 'first',
8 follows: 'first',
9 followers: 'first'
10}
11
12exports.gives = 'avatar_profile'
13
14/*
15function streamToList(stream, el) {
16 pull(
17 stream,
18 pull.drain(function (item) {
19 if(item) el.appendChild(item)
20 })
21 )
22 return el
23}*/
24
25exports.create = function (api) {
26 //function image_link (id) {
27 // return api.avatar_image_link(id, 'thumbnail')
28 //}
29
30 return function (id) {
31 /*
32 var follows_el = h('div.profile__follows.wrap')
33 var friends_el = h('div.profile__friendss.wrap')
34 var followers_el = h('div.profile__followers.wrap')
35 var a, b
36
37 pull(api.follows(id), pull.unique(), pull.collect(function (err, ary) {
38 a = ary || []; next()
39 }))
40 pull(api.followers(id), pull.unique(), pull.collect(function (err, ary) {
41 b = ary || {}; next()
42 }))
43
44 function next () {
45 if(!(a && b)) return
46 var _c = [], _a = [], _b = []
47
48 a.forEach(function (id) {
49 if(!~b.indexOf(id)) _a.push(id)
50 else _c.push(id)
51 })
52 b.forEach(function (id) {
53 if(!~_c.indexOf(id)) _b.push(id)
54 })
55 function add (ary, el) {
56 ary.forEach(function (id) { el.appendChild(image_link(id)) })
57 }
58
59 add(_a, follows_el)
60 add(_c, friends_el)
61 add(_b, followers_el)
62 }
63 */
64 return h('div.column.profile',
65 api.avatar_edit(id),
66 api.avatar_action(id)
67 /*
68 h('div.profile__relationships.column',
69 h('strong', 'follows'),
70 follows_el,
71 h('strong', 'friends'),
72 friends_el,
73 h('strong', 'followers'),
74 followers_el
75 )
76 */
77 )
78 }
79}
80
81

Built with git-ssb-web