git ssb

2+

mixmix / ticktack



Tree: 26ec4bc385c250f6b9b1d0eb534ceaff0f876083

Files: 26ec4bc385c250f6b9b1d0eb534ceaff0f876083 / app / page / userShow.js

3291 bytesRaw
1const nest = require('depnest')
2const { h, Array: MutantArray, computed, when, map } = require('mutant')
3const pull = require('pull-stream')
4const get = require('lodash/get')
5const path = require('path')
6
7exports.gives = nest('app.page.userShow')
8
9exports.needs = nest({
10 'about.html.avatar': 'first',
11 'about.obs.name': 'first',
12 'about.obs.description': 'first',
13 'app.html.link': 'first',
14 'app.html.blogCard': 'first',
15 'app.html.topNav': 'first',
16 'app.html.scroller': 'first',
17 'app.html.sideNav': 'first',
18 'blog.sync.isBlog': 'first',
19 'contact.html.follow': 'first',
20 'contact.html.block': 'first',
21 'feed.pull.profile': 'first',
22 'feed.pull.rollup': 'first',
23 'message.html.markdown': 'first',
24 'keys.sync.id': 'first',
25 'sbot.pull.userFeed': 'first',
26 'translations.sync.strings': 'first',
27 'unread.sync.isUnread': 'first'
28})
29
30exports.create = (api) => {
31 var isUnread = api.unread.sync.isUnread
32 return nest('app.page.userShow', userShow)
33
34 function userShow (location) {
35 const { feed } = location
36 const myId = api.keys.sync.id()
37
38 const strings = api.translations.sync.strings()
39
40 const Link = api.app.html.link
41 const userEditButton = Link(
42 { page: 'userEdit', feed },
43 // h('i.fa.fa-pencil')
44 h('img', { src: path.join(__dirname, '../../assets', 'edit.png') })
45 )
46 const directMessageButton = Link({ page: 'threadNew', participants: [feed] }, h('Button', strings.userShow.action.directMessage))
47
48 // TODO return some of this ?
49 // but maybe this shouldn't be done here ?
50 // pull.through(function (blog) {
51 // if(isUnread(blog))
52 // blog.unread = true
53 // blog.replies.forEach(function (data) { // this was fed rollups
54 // if(isUnread(data))
55 // blog.unread = data.unread = true
56 // })
57 // }),
58
59 const prepend = [
60 api.app.html.topNav(location),
61 h('section.about', [
62 api.about.html.avatar(feed, 'large'),
63 h('h1', [
64 api.about.obs.name(feed),
65 feed === myId // Only expose own profile editing right now
66 ? userEditButton
67 : ''
68 ]),
69 h('div.introduction', computed(api.about.obs.description(feed), d => api.message.html.markdown(d || ''))),
70 feed !== myId
71 ? h('div.actions', [
72 h('div.directMessage', directMessageButton),
73 api.contact.html.follow(feed),
74 api.contact.html.block(feed)
75 ])
76 : ''
77 ])
78 ]
79
80 const store = MutantArray()
81 // store(console.log)
82
83 return h('Page -userShow', [
84 api.app.html.sideNav(location),
85 api.app.html.scroller({
86 classList: ['content'],
87 prepend,
88 // stream: api.feed.pull.profile(feed),
89 stream: opts => api.sbot.pull.userFeed(Object.assign({}, { id: feed }, opts)),
90 indexProperty: ['value', 'sequence'],
91 filter: () => pull(
92 // pull.filter(msg => get(msg, 'value.author') === feed),
93 pull.filter(msg => typeof msg.value.content !== 'string'),
94 pull.filter(msg => get(msg, 'value.content.root') === undefined),
95 pull.filter(api.blog.sync.isBlog)
96 ),
97 render: blog => {
98 return api.app.html.blogCard(blog)
99 },
100 store
101 })
102 ])
103 }
104}
105

Built with git-ssb-web