git ssb

16+

Dominic / patchbay



Tree: de41793084dc0680dd57842ec2fec0c18ac702e9

Files: de41793084dc0680dd57842ec2fec0c18ac702e9 / router / html / page / profile.js

1823 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 'router.html.page': true
10})
11// menu_items
12
13exports.needs = nest({
14 'about.obs': {
15 'name': 'first'
16 // 'description': 'first',
17 // 'image': 'first',
18 // 'imageUrl',
19 // 'names',
20 // 'images',
21 },
22 'keys.sync.id': 'first',
23 'main.html.scroller': 'first',
24 'message.html.render': 'first',
25 'sbot.pull.userFeed': 'first'
26})
27
28
29exports.create = function (api) {
30 return nest({
31 'router.html.page': page
32 })
33 // menu_items: () => h('a', {
34 // href: '#'+self_id,
35 // style: { order: 1 }
36 // }, '/profile')
37
38 function page (id) {
39 if (!ref.isFeed(id)) return
40
41 const profile = h('Profile', [
42 // h('section.edit', api.about.edit(id)),
43 // h('section.relationships', api.contact.relationships(id)),
44 h('section.activity', [
45 h('header', 'Activity')
46 // ideally the scroller content would go in here
47 ])
48 ])
49
50 var { container, content } = api.main.html.scroller({ prepend: profile })
51
52 const name = api.about.obs.name(id)
53 watch(name, name => container.title = '@'+name)
54 container.id = id
55
56 pull(
57 api.sbot.pull.userFeed({id: id, old: false, live: true}),
58 Scroller(container, content, api.message.html.render, true, false)
59 )
60
61 //how to handle when have scrolled past the start???
62
63 pull(
64 next(api.sbot.pull.userFeed, { id: id, reverse: true, limit: 50, live: false }, ['value', 'sequence']),
65 // pull.through(console.log.bind(console)),
66 Scroller(container, content, api.message.html.render, false, false)
67 )
68
69 return container
70 }
71}
72
73
74

Built with git-ssb-web