git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: c50f73d28c82ec782f6fca2e0a41d3b4d138becb

Files: c50f73d28c82ec782f6fca2e0a41d3b4d138becb / modules / message / async / publish.js

968 bytesRaw
1var h = require('mutant/h')
2var nest = require('depnest')
3
4exports.needs = nest({
5 'sheet.display': 'first',
6 'message.html.render': 'first',
7 'sbot.async.publish': 'first',
8 'keys.sync.id': 'first'
9})
10
11exports.gives = nest('message.async.publish')
12
13exports.create = function (api) {
14 return nest('message.async.publish', function (content, cb) {
15 api.sheet.display(function (close) {
16 return {
17 content: [
18 api.message.html.render({value: {
19 content,
20 private: !!content.recps,
21 author: api.keys.sync.id()
22 }})
23 ],
24 footer: [
25 h('button -save', { 'ev-click': publish }, 'Confirm'),
26 h('button -cancel', { 'ev-click': cancel }, 'Cancel')
27 ]
28 }
29
30 function publish () {
31 close()
32 api.sbot.async.publish(content, cb)
33 }
34
35 function cancel () {
36 close()
37 cb && cb(null, false)
38 }
39 })
40 return true
41 })
42}
43

Built with git-ssb-web