git ssb

2+

mixmix / ticktack



Tree: 48dc57fc8ae627b623bd0e844841403c70e9e383

Files: 48dc57fc8ae627b623bd0e844841403c70e9e383 / app / page / userShow.js

2952 bytesRaw
1const nest = require('depnest')
2const { h, Array: MutantArray, computed, when, map } = require('mutant')
3const pull = require('pull-stream')
4const get = require('lodash/get')
5
6exports.gives = nest('app.page.userShow')
7
8exports.needs = nest({
9 'about.html.avatar': 'first',
10 'about.obs.name': 'first',
11 'app.html.link': 'first',
12 'app.html.blogCard': 'first',
13 'contact.html.follow': 'first',
14 'feed.pull.private': 'first',
15 'sbot.pull.userFeed': 'first',
16 'keys.sync.id': 'first',
17 'translations.sync.strings': 'first',
18})
19
20exports.create = (api) => {
21 return nest('app.page.userShow', userShow)
22
23 function userShow (location) {
24
25 const { feed } = location
26 const myId = api.keys.sync.id()
27 const name = api.about.obs.name(feed)
28
29 const strings = api.translations.sync.strings()
30
31 // const { followers } = api.contact.obs
32
33 // const youFollowThem = computed(followers(feed), followers => followers.includes(myId))
34 // const theyFollowYou = computed(followers(myId), followers => followers.includes(feed))
35 // const youAreFriends = computed([youFollowThem, theyFollowYou], (a, b) => a && b)
36
37 // const ourRelationship = computed(
38 // [youAreFriends, youFollowThem, theyFollowYou],
39 // (youAreFriends, youFollowThem, theyFollowYou) => {
40 // if (youAreFriends) return strings.userShow.state.friends
41 // if (theyFollowYou) return strings.userShow.state.theyFollow
42 // if (youFollowThem) return strings.userShow.state.youFollow
43 // }
44 // )
45
46 const Link = api.app.html.link
47 const userEditButton = Link({ page: 'userEdit', feed }, h('i.fa.fa-pencil'))
48 const directMessageButton = Link({ page: 'threadNew', feed }, h('Button', strings.userShow.action.directMessage))
49
50 const BLOG_TYPES = ['blog', 'post']
51 const blogs = MutantArray()
52 pull(
53 // next(api.feed.pull.private, {reverse: true, limit: 100, live: false}, ['value', 'timestamp']),
54 // api.feed.pull.private({reverse: true, limit: 100, live: false}),
55 api.sbot.pull.userFeed({id: feed, reverse: true, live: false}),
56 pull.filter(msg => BLOG_TYPES.includes(get(msg, 'value.content.type'))),
57 pull.filter(msg => get(msg, 'value.content.root') === undefined),
58 pull.drain(blogs.push)
59 // Scroller(content, scrollerContent, render, false, false)
60 )
61
62 return h('Page -userShow', {title: name}, [
63 h('div.content', [
64 h('section.about', [
65 api.about.html.avatar(feed, 'large'),
66 h('h1', [
67 name,
68 feed === myId // Only expose own profile editing right now
69 ? userEditButton
70 : ''
71 ]),
72 feed !== myId
73 ? h('div.actions', [
74 api.contact.html.follow(feed),
75 h('div.directMessage', directMessageButton)
76 ])
77 : '',
78 ]),
79 h('section.blogs', map(blogs, api.app.html.blogCard))
80 ])
81 ])
82 }
83}
84
85
86

Built with git-ssb-web