Files: a5417350593eb41e7c3b56c8edf96aa895411fb2 / modules / channel.js
1186 bytesRaw
1 | var plugs = require('patchbay/plugs') |
2 | var extend = require('xtend') |
3 | var message_compose = plugs.first(exports.message_compose = []) |
4 | var sbot_log = plugs.first(exports.sbot_log = []) |
5 | var feed_summary = plugs.first(exports.feed_summary = []) |
6 | var h = require('hyperscript') |
7 | var pull = require('pull-stream') |
8 | var sbot_query = plugs.first(exports.sbot_query = []) |
9 | |
10 | exports.screen_view = function (path, sbot) { |
11 | if (path[0] === '#') { |
12 | var channel = path.substr(1) |
13 | return feed_summary((opts) => { |
14 | if (opts.old === false) { |
15 | return pull( |
16 | sbot_log(opts), |
17 | pull.filter(matchesChannel) |
18 | ) |
19 | } else { |
20 | return sbot_query(extend(opts, {query: [ |
21 | {$filter: {value: {content: {channel: channel}}}} |
22 | ]})) |
23 | } |
24 | }, [ |
25 | message_compose({type: 'post', channel: channel}) |
26 | ]) |
27 | } |
28 | |
29 | // scoped |
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 | |
38 | exports.message_meta = function (msg) { |
39 | var chan = msg.value.content.channel |
40 | if (chan) { |
41 | return h('a', {href: '##' + chan}, '#' + chan) |
42 | } |
43 | } |
44 |
Built with git-ssb-web