git ssb

16+

Dominic / patchbay



Commit 0a1c7842563bee8ca52221c858cfe7309da160da

minimal private message feed

mix irving committed on 2/26/2017, 2:01:23 AM
Parent: 1a1110c2e82bfc339186396f16b13e1ed2425d4c

Files changed

router/html/page/private.jschanged
router/html/page/public.jschanged
router/html/page/private.jsView
@@ -1,13 +1,52 @@
11 const { h } = require('mutant')
22 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')
37
48 exports.gives = nest('router.html.page')
59
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+
620 exports.create = function (api) {
7- return nest('router.html.page', (path) => {
21+ return nest('router.html.page', privatePage)
22+
23+ function privatePage (path) {
824 if (path !== '/private') return
925
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+ }
1251 }
1352
router/html/page/public.jsView
@@ -1,39 +1,40 @@
11 const { h } = require('mutant')
22 const nest = require('depnest')
33 const pull = require('pull-stream')
44 const Scroller = require('pull-scroll')
5-
65 const next = require('../../../junk/next-stepper')
76
87 exports.gives = nest('router.html.page')
98
109 exports.needs = nest({
11- 'sbot.pull.log': 'first',
10+ 'feed.pull.public': 'first',
1211 'message.html': {
1312 compose: 'first',
1413 render: 'first',
1514 },
1615 'main.html.scroller': 'first'
1716 })
1817
1918 exports.create = function (api) {
20- return nest('router.html.page', (path) => {
19+ return nest('router.html.page', publicPage)
20+
21+ function publicPage (path) {
2122 if (path !== '/public') return
2223
2324 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 })
2526
2627 pull(
27- next(api.sbot.pull.log, {old: false, limit: 100}),
28+ next(api.feed.pull.public, {old: false, limit: 100}),
2829 Scroller(container, content, api.message.html.render, true, false)
2930 )
3031
3132 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}),
3334 Scroller(container, content, api.message.html.render, false, false)
3435 )
3536
3637 return container
37- })
38+ }
3839 }
3940

Built with git-ssb-web