Files: 9510d7867738dfa7a4aaee17c183c86bb081f55e / app / page / profile.js
1908 bytesRaw
1 | const nest = require('depnest') |
2 | const Scroller = require('pull-scroll') |
3 | const pull = require('pull-stream') |
4 | const { h, watch } = require('mutant') |
5 | |
6 | const next = require('../../junk/next-stepper') |
7 | |
8 | exports.gives = nest({ |
9 | 'app.html.menuItem': true, |
10 | 'app.page.profile': true, |
11 | }) |
12 | |
13 | exports.needs = nest({ |
14 | 'about': { |
15 | 'html.edit': 'first', |
16 | 'obs.name': 'first' |
17 | }, |
18 | 'app.html.scroller': 'first', |
19 | 'app.sync.goTo': 'first', |
20 | 'contact.html.relationships': 'first', |
21 | 'keys.sync.id': 'first', |
22 | 'message.html.render': 'first', |
23 | 'sbot.pull.userFeed': 'first' |
24 | }) |
25 | |
26 | exports.create = function (api) { |
27 | return nest({ |
28 | 'app.html.menuItem': menuItem, |
29 | 'app.page.profile': profilePage, |
30 | }) |
31 | |
32 | function menuItem () { |
33 | return h('a', { |
34 | style: { order: 0 }, |
35 | 'ev-click': () => api.app.sync.goTo(api.keys.sync.id()) |
36 | }, '/profile') |
37 | } |
38 | |
39 | function profilePage (location) { |
40 | const { feed: id } = location |
41 | const profile = h('Profile', [ |
42 | h('section.edit', api.about.html.edit(id)), |
43 | h('section.relationships', api.contact.html.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.app.html.scroller({ prepend: profile }) |
51 | |
52 | |
53 | pull( |
54 | api.sbot.pull.userFeed({id: id, old: false, live: true}), |
55 | Scroller(container, content, api.message.html.render, true, false) |
56 | ) |
57 | |
58 | // how to handle when have scrolled past the start??? |
59 | |
60 | pull( |
61 | next(api.sbot.pull.userFeed, { id: id, reverse: true, limit: 50, live: false }, ['value', 'sequence']), |
62 | // pull.through(console.log.bind(console)), |
63 | Scroller(container, content, api.message.html.render, false, false) |
64 | ) |
65 | |
66 | container.id = JSON.stringify(location) |
67 | watch(api.about.obs.name(id), name => { container.title = '@' + name }) |
68 | return container |
69 | } |
70 | } |
71 | |
72 |
Built with git-ssb-web