Files: 7f36af61c5b02eabf69bac7fb45f5ac923956922 / modules / channel.js
1412 bytesRaw
1 | var h = require('hyperscript') |
2 | var u = require('../util') |
3 | var pull = require('pull-stream') |
4 | var Scroller = require('pull-scroll') |
5 | |
6 | var plugs = require('../plugs') |
7 | var message_render = plugs.first(exports.message_render = []) |
8 | var message_compose = plugs.first(exports.message_compose = []) |
9 | var sbot_log = plugs.first(exports.sbot_log = []) |
10 | var sbot_query = plugs.first(exports.sbot_query = []) |
11 | |
12 | exports.message_meta = function (msg) { |
13 | var chan = msg.value.content.channel |
14 | if (chan) |
15 | return h('a', {href: '##'+chan}, '#'+chan) |
16 | } |
17 | |
18 | exports.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