Commit 0a1c7842563bee8ca52221c858cfe7309da160da
minimal private message feed
mix irving committed on 2/26/2017, 2:01:23 AMParent: 1a1110c2e82bfc339186396f16b13e1ed2425d4c
Files changed
router/html/page/private.js | changed |
router/html/page/public.js | changed |
router/html/page/private.js | ||
---|---|---|
@@ -1,13 +1,52 @@ | ||
1 | 1 | const { h } = require('mutant') |
2 | 2 | const nest = require('depnest') |
3 | +const pull = require('pull-stream') | |
4 | +const Scroller = require('pull-scroll') | |
5 | +const next = require('../../../junk/next-stepper') | |
6 | +const ref = require('ssb-ref') | |
3 | 7 | |
4 | 8 | exports.gives = nest('router.html.page') |
5 | 9 | |
10 | +exports.needs = nest({ | |
11 | + 'feed.pull.private': 'first', | |
12 | + 'keys.sync.id': 'first', | |
13 | + 'main.html.scroller': 'first', | |
14 | + 'message.html': { | |
15 | + compose: 'first', | |
16 | + render: 'first', | |
17 | + }, | |
18 | +}) | |
19 | + | |
6 | 20 | exports.create = function (api) { |
7 | - return nest('router.html.page', (path) => { | |
21 | + return nest('router.html.page', privatePage) | |
22 | + | |
23 | + function privatePage (path) { | |
8 | 24 | if (path !== '/private') return |
9 | 25 | |
10 | - return h('div.private', 'private') | |
11 | - }) | |
26 | + const id = api.keys.sync.id() | |
27 | + | |
28 | + const composer = api.message.html.compose({ | |
29 | + meta: { type: 'post' }, | |
30 | + prepublish: meta => { | |
31 | + meta.recps = [id, ...meta.mentions] | |
32 | + .filter(m => ref.isFeed(typeof m === 'string' ? m : m.link)) | |
33 | + return meta | |
34 | + }, | |
35 | + placeholder: 'Write a private message. \n\n@mention users in the first message to start a private thread.'} | |
36 | + ) | |
37 | + const { container, content } = api.main.html.scroller({ prepend: composer }) | |
38 | + | |
39 | + pull( | |
40 | + next(api.feed.pull.private, {old: false, limit: 100}), | |
41 | + Scroller(container, content, api.message.html.render, true, false) | |
42 | + ) | |
43 | + | |
44 | + pull( | |
45 | + next(api.feed.pull.private, {reverse: true, limit: 100, live: false}), | |
46 | + Scroller(container, content, api.message.html.render, false, false) | |
47 | + ) | |
48 | + | |
49 | + return container | |
50 | + } | |
12 | 51 | } |
13 | 52 |
router/html/page/public.js | ||
---|---|---|
@@ -1,39 +1,40 @@ | ||
1 | 1 | const { h } = require('mutant') |
2 | 2 | const nest = require('depnest') |
3 | 3 | const pull = require('pull-stream') |
4 | 4 | const Scroller = require('pull-scroll') |
5 | - | |
6 | 5 | const next = require('../../../junk/next-stepper') |
7 | 6 | |
8 | 7 | exports.gives = nest('router.html.page') |
9 | 8 | |
10 | 9 | exports.needs = nest({ |
11 | - 'sbot.pull.log': 'first', | |
10 | + 'feed.pull.public': 'first', | |
12 | 11 | 'message.html': { |
13 | 12 | compose: 'first', |
14 | 13 | render: 'first', |
15 | 14 | }, |
16 | 15 | 'main.html.scroller': 'first' |
17 | 16 | }) |
18 | 17 | |
19 | 18 | exports.create = function (api) { |
20 | - return nest('router.html.page', (path) => { | |
19 | + return nest('router.html.page', publicPage) | |
20 | + | |
21 | + function publicPage (path) { | |
21 | 22 | if (path !== '/public') return |
22 | 23 | |
23 | 24 | const composer = api.message.html.compose({ meta: { type: 'post' }, placeholder: 'Write a public message'}) |
24 | - var { container, content } = api.main.html.scroller({ prepend: composer }) | |
25 | + const { container, content } = api.main.html.scroller({ prepend: composer }) | |
25 | 26 | |
26 | 27 | pull( |
27 | - next(api.sbot.pull.log, {old: false, limit: 100}), | |
28 | + next(api.feed.pull.public, {old: false, limit: 100}), | |
28 | 29 | Scroller(container, content, api.message.html.render, true, false) |
29 | 30 | ) |
30 | 31 | |
31 | 32 | pull( |
32 | - next(api.sbot.pull.log, {reverse: true, limit: 100, live: false}), | |
33 | + next(api.feed.pull.public, {reverse: true, limit: 100, live: false}), | |
33 | 34 | Scroller(container, content, api.message.html.render, false, false) |
34 | 35 | ) |
35 | 36 | |
36 | 37 | return container |
37 | - }) | |
38 | + } | |
38 | 39 | } |
39 | 40 |
Built with git-ssb-web