git ssb

16+

Dominic / patchbay



Tree: 567b32727710add1401610208245e6950f200f06

Files: 567b32727710add1401610208245e6950f200f06 / modules / channel.js

1453 bytesRaw
1var h = require('hyperscript')
2var u = require('../util')
3var pull = require('pull-stream')
4var Scroller = require('pull-scroll')
5
6var plugs = require('../plugs')
7var message_render = plugs.first(exports.message_render = [])
8var message_compose = plugs.first(exports.message_compose = [])
9var sbot_log = plugs.first(exports.sbot_log = [])
10
11exports.message_meta = function (msg) {
12 var chan = msg.value.content.channel
13 if (chan)
14 return h('a', {href: '##'+chan}, '#'+chan)
15}
16
17exports.screen_view = function (path) {
18 if(path[0] === '#') {
19 var channel = path.substr(1)
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 message_compose({type: 'post'}), //header
26 content
27 )
28 )
29
30 function matchesChannel(msg) {
31 if (msg.sync) console.error('SYNC', msg)
32 var c = msg && msg.value && msg.value.content
33 return c && c.channel === channel
34 }
35
36 pull(
37 sbot_log({old: false}),
38 pull.filter(matchesChannel),
39 Scroller(div, content, message_render, true, false)
40 )
41
42 pull(
43 /*
44 sbot_query({query: [
45 {$filter: {value: {content: {channel: channel}}}}
46 ]}),
47 */
48 u.next(sbot_log, {reverse: true, limit: 100, live: false}),
49 pull.filter(matchesChannel),
50 Scroller(div, content, message_render, false, false)
51 )
52
53 return div
54 }
55}
56

Built with git-ssb-web