router/html/page/profile.jsView |
---|
| 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 | + |
| 12 | + |
| 13 | +exports.needs = nest({ |
| 14 | + 'about.obs': { |
| 15 | + 'name': 'first' |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + }, |
| 22 | + 'keys.sync.id': 'first', |
| 23 | + 'main.html.scroller': 'first', |
| 24 | + 'message.html.render': 'first', |
| 25 | + 'sbot.pull.userFeed': 'first' |
| 26 | +}) |
| 27 | + |
| 28 | + |
| 29 | +exports.create = function (api) { |
| 30 | + return nest({ |
| 31 | + 'router.html.page': page |
| 32 | + }) |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + function page (id) { |
| 39 | + if (!ref.isFeed(id)) return |
| 40 | + |
| 41 | + const profile = h('Profile', [ |
| 42 | + |
| 43 | + |
| 44 | + h('section.activity', [ |
| 45 | + h('header', 'Activity') |
| 46 | + |
| 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 | + |
| 62 | + |
| 63 | + pull( |
| 64 | + next(api.sbot.pull.userFeed, { id: id, reverse: true, limit: 50, live: false }, ['value', 'sequence']), |
| 65 | + |
| 66 | + Scroller(container, content, api.message.html.render, false, false) |
| 67 | + ) |
| 68 | + |
| 69 | + return container |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | + |