Files: c431b9f86d04597436c8fd31782d8ab7a1a65f4e / modules_basic / feed.js
1262 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 | |
32 | pull( |
33 | api.sbot_user_feed({id: id, old: false, live: true}), |
34 | Scroller(container, content, api.message_render, true, false) |
35 | ) |
36 | |
37 | //how to handle when have scrolled past the start??? |
38 | |
39 | pull( |
40 | u.next(api.sbot_user_feed, { |
41 | id: id, reverse: true, |
42 | limit: 50, live: false |
43 | }, ['value', 'sequence']), |
44 | // pull.through(console.log.bind(console)), |
45 | Scroller(container, content, api.message_render, false, false) |
46 | ) |
47 | |
48 | return container |
49 | } |
50 | } |
51 | |
52 |
Built with git-ssb-web