git ssb

16+

Dominic / patchbay



Tree: 038e248915e3e8c69af62015ec1eb52f957d79f3

Files: 038e248915e3e8c69af62015ec1eb52f957d79f3 / app / html / page / profile.js

1923 bytesRaw
1const nest = require('depnest')
2const ref = require('ssb-ref')
3const Scroller = require('pull-scroll')
4const pull = require('pull-stream')
5const { h, watch } = require('mutant')
6const next = require('../../../junk/next-stepper')
7
8exports.gives = nest({
9 'app.html': {
10 page: true,
11 menuItem: true
12 }
13})
14
15exports.needs = nest({
16 'about.html.edit': 'first',
17 'about.obs': {
18 'name': 'first'
19 },
20 'contact.html.relationships': 'first',
21 'keys.sync.id': 'first',
22 'app.html.scroller': 'first',
23 'message.html.render': 'first',
24 'sbot.pull.userFeed': 'first'
25})
26
27exports.create = function (api) {
28 return nest({
29 'app.html': {
30 page: profilePage,
31 menuItem: menuItem
32 }
33 })
34
35 function menuItem (handleClick) {
36 return h('a', {
37 style: { order: 0 },
38 'ev-click': () => handleClick(api.keys.sync.id())
39 }, '/profile')
40 }
41
42 function profilePage (id) {
43 if (!ref.isFeed(id)) return
44
45 const profile = h('Profile', [
46 h('section.edit', api.about.html.edit(id)),
47 h('section.relationships', api.contact.html.relationships(id)),
48 h('section.activity', [
49 h('header', 'Activity')
50 // ideally the scroller content would go in here
51 ])
52 ])
53
54 var { container, content } = api.app.html.scroller({ prepend: profile })
55
56 const name = api.about.obs.name(id)
57 watch(name, function (name) { container.title = '@' + name })
58 container.id = id
59
60 pull(
61 api.sbot.pull.userFeed({id: id, old: false, live: true}),
62 Scroller(container, content, api.message.html.render, true, false)
63 )
64
65 // how to handle when have scrolled past the start???
66
67 pull(
68 next(api.sbot.pull.userFeed, { id: id, reverse: true, limit: 50, live: false }, ['value', 'sequence']),
69 // pull.through(console.log.bind(console)),
70 Scroller(container, content, api.message.html.render, false, false)
71 )
72
73 return container
74 }
75}
76
77

Built with git-ssb-web