git ssb

10+

Matt McKegg / patchwork



Tree: 149c021b55e9957ad4d75789d066cf9794507064

Files: 149c021b55e9957ad4d75789d066cf9794507064 / 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