Files: b62ecd6f843b26f37e70c7b6d65c71db35bbf922 / modules / feed.js
1209 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 | exports.create = function (api) { |
17 | |
18 | return function (id) { |
19 | if(ref.isFeed(id)) { |
20 | |
21 | var content = h('div.column.scroller__content') |
22 | var div = h('div.column.scroller', |
23 | {style: {'overflow':'auto'}}, |
24 | h('div.scroller__wrapper', |
25 | h('div', api.avatar_profile(id)), |
26 | content |
27 | ) |
28 | ) |
29 | |
30 | api.signifier(id, function (_, names) { |
31 | if(names.length) div.title = names[0].name |
32 | }) |
33 | |
34 | pull( |
35 | api.sbot_user_feed({id: id, old: false, live: true}), |
36 | Scroller(div, content, api.message_render, true, false) |
37 | ) |
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(div, content, api.message_render, false, false) |
46 | ) |
47 | |
48 | return div |
49 | } |
50 | } |
51 | } |
52 | |
53 |
Built with git-ssb-web