Files: 3f6f0c96bdbbd8307fb9e5459b6857870001abfc / modules_basic / feed.js
1329 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 | content |
30 | ) |
31 | ) |
32 | |
33 | api.signifier(id, function (_, names) { |
34 | if(names.length) div.title = names[0].name |
35 | }) |
36 | |
37 | |
38 | pull( |
39 | api.sbot_user_feed({id: id, old: false, live: true}), |
40 | Scroller(div, content, api.message_render, true, false) |
41 | ) |
42 | |
43 | //how to handle when have scrolled past the start??? |
44 | |
45 | pull( |
46 | u.next(api.sbot_user_feed, { |
47 | id: id, reverse: true, |
48 | limit: 50, live: false |
49 | }, ['value', 'sequence']), |
50 | pull.through(console.log.bind(console)), |
51 | Scroller(div, content, api.message_render, false, false) |
52 | ) |
53 | |
54 | return div |
55 | |
56 | } |
57 | } |
58 | |
59 | } |
60 | |
61 |
Built with git-ssb-web