git ssb

16+

Dominic / patchbay



Tree: c38e965ff14b9067041ae577f0d73337d043aebf

Files: c38e965ff14b9067041ae577f0d73337d043aebf / app / html / page / profile.js

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

Built with git-ssb-web