git ssb

16+

Dominic / patchbay



Tree: d5d67784390b67e685e8675d95cabae952961b35

Files: d5d67784390b67e685e8675d95cabae952961b35 / app / page / profile.js

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

Built with git-ssb-web