git ssb

16+

Dominic / patchbay



Tree: d0b1c05b483fa6de9080159f9713c98893cdb358

Files: d0b1c05b483fa6de9080159f9713c98893cdb358 / modules_extra / channel.js

1412 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 = [])
10var sbot_query = plugs.first(exports.sbot_query = [])
11
12exports.message_meta = function (msg) {
13 var chan = msg.value.content.channel
14 if (chan)
15 return h('a', {href: '##'+chan}, '#'+chan)
16}
17
18exports.screen_view = function (path) {
19 if(path[0] === '#') {
20 var channel = path.substr(1)
21
22 var content = h('div.column.scroller__content')
23 var div = h('div.column.scroller',
24 {style: {'overflow':'auto'}},
25 h('div.scroller__wrapper',
26 message_compose({type: 'post', channel: channel}),
27 content
28 )
29 )
30
31 function matchesChannel(msg) {
32 if (msg.sync) console.error('SYNC', msg)
33 var c = msg && msg.value && msg.value.content
34 return c && c.channel === channel
35 }
36
37 pull(
38 sbot_log({old: false}),
39 pull.filter(matchesChannel),
40 Scroller(div, content, message_render, true, false)
41 )
42
43 pull(
44 sbot_query({reverse: true, query: [
45 {$filter: {value: {content: {channel: channel}}}}
46 ]}),
47 Scroller(div, content, message_render, false, false)
48 )
49
50 return div
51 }
52}
53

Built with git-ssb-web