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