git ssb

16+

Dominic / patchbay



Tree: d34b731ad8a333e287d614895dc8ee066f7a59da

Files: d34b731ad8a333e287d614895dc8ee066f7a59da / modules_basic / feed.js

1284 bytesRaw
1var ref = require('ssb-ref')
2var Scroller = require('pull-scroll')
3var h = require('hyperscript')
4var pull = require('pull-stream')
5var u = require('../util')
6
7exports.needs = {
8 build_scroller: 'first',
9 sbot_user_feed: 'first',
10 message_render: 'first',
11 avatar_profile: 'first',
12 signifier: 'first'
13}
14
15exports.gives = 'screen_view'
16
17
18exports.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 container.id = id
32
33 pull(
34 api.sbot_user_feed({id: id, old: false, live: true}),
35 Scroller(container, content, api.message_render, true, false)
36 )
37
38 //how to handle when have scrolled past the start???
39
40 pull(
41 u.next(api.sbot_user_feed, {
42 id: id, reverse: true,
43 limit: 50, live: false
44 }, ['value', 'sequence']),
45 // pull.through(console.log.bind(console)),
46 Scroller(container, content, api.message_render, false, false)
47 )
48
49 return container
50 }
51}
52
53

Built with git-ssb-web