Files: 1d62bb3c81414c6538c54c367803bce3f2516a68 / modules_basic / feed.js
1284 bytesRaw
1 | var ref = require('ssb-ref') |
2 | var Scroller = require('pull-scroll') |
3 | var h = require('hyperscript') |
4 | var pull = require('pull-stream') |
5 | var u = require('../util') |
6 | |
7 | exports.needs = { |
8 | build_scroller: 'first', |
9 | sbot_user_feed: 'first', |
10 | message_render: 'first', |
11 | avatar_profile: 'first', |
12 | signifier: 'first' |
13 | } |
14 | |
15 | exports.gives = 'screen_view' |
16 | |
17 | |
18 | exports.create = function (api) { |
19 | |
20 | return function (id) { |
21 | //TODO: header of user info, avatars, names, follows. |
22 | |
23 | if(!ref.isFeed(id)) return |
24 | |
25 | const profile = h('div', api.avatar_profile(id)) |
26 | var { container, content } = api.build_scroller({ prepend: [profile, h('header', 'Activity')] }) |
27 | |
28 | api.signifier(id, function (_, names) { |
29 | if(names.length) container.title = names[0].name |
30 | }) |
31 | container.id = id |
32 | |
33 | pull( |
34 | api.sbot_user_feed({id: id, old: false, live: true}), |
35 | Scroller(container, content, api.message_render, true, false) |
36 | ) |
37 | |
38 | //how to handle when have scrolled past the start??? |
39 | |
40 | pull( |
41 | u.next(api.sbot_user_feed, { |
42 | id: id, reverse: true, |
43 | limit: 50, live: false |
44 | }, ['value', 'sequence']), |
45 | // pull.through(console.log.bind(console)), |
46 | Scroller(container, content, api.message_render, false, false) |
47 | ) |
48 | |
49 | return container |
50 | } |
51 | } |
52 | |
53 |
Built with git-ssb-web