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