Files: 3b0cb72e5d99d144b36ae7497086b1cc81b13384 / modules_basic / feed.js
1367 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 | sbot_user_feed: 'first', |
9 | message_render: 'first', |
10 | avatar_profile: 'first', |
11 | signifier: 'first' |
12 | } |
13 | |
14 | exports.gives = 'screen_view' |
15 | |
16 | |
17 | exports.create = function (api) { |
18 | |
19 | return function (id) { |
20 | //TODO: header of user info, avatars, names, follows. |
21 | |
22 | if(ref.isFeed(id)) { |
23 | |
24 | var content = h('div.column.scroller__content') |
25 | var div = h('div.column.scroller', |
26 | {style: {'overflow':'auto'}}, |
27 | h('div.scroller__wrapper', |
28 | h('div', api.avatar_profile(id)), |
29 | h('header', 'Activity'), |
30 | content |
31 | ) |
32 | ) |
33 | |
34 | api.signifier(id, function (_, names) { |
35 | if(names.length) div.title = names[0].name |
36 | }) |
37 | |
38 | |
39 | pull( |
40 | api.sbot_user_feed({id: id, old: false, live: true}), |
41 | Scroller(div, content, api.message_render, true, false) |
42 | ) |
43 | |
44 | //how to handle when have scrolled past the start??? |
45 | |
46 | pull( |
47 | u.next(api.sbot_user_feed, { |
48 | id: id, reverse: true, |
49 | limit: 50, live: false |
50 | }, ['value', 'sequence']), |
51 | // pull.through(console.log.bind(console)), |
52 | Scroller(div, content, api.message_render, false, false) |
53 | ) |
54 | |
55 | return div |
56 | |
57 | } |
58 | } |
59 | |
60 | } |
61 | |
62 |
Built with git-ssb-web