git ssb

10+

Matt McKegg / patchwork



Tree: 20e56e6bb267f73d48091b7c9576ae3f9bab0bee

Files: 20e56e6bb267f73d48091b7c9576ae3f9bab0bee / modules / message / async / publish.js

1043 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 'intl.sync.i18n': 'first'
10})
11
12exports.gives = nest('message.async.publish')
13
14exports.create = function (api) {
15 const i18n = api.intl.sync.i18n
16 return nest('message.async.publish', function (content, cb) {
17 api.sheet.display(function (close) {
18 return {
19 content: [
20 api.message.html.render({value: {
21 content,
22 private: !!content.recps,
23 author: api.keys.sync.id()
24 }})
25 ],
26 footer: [
27 h('button -save', { 'ev-click': publish }, i18n('Confirm')),
28 h('button -cancel', { 'ev-click': cancel }, i18n('Cancel'))
29 ]
30 }
31
32 function publish () {
33 close()
34 api.sbot.async.publish(content, cb)
35 }
36
37 function cancel () {
38 close()
39 cb && cb(null, false)
40 }
41 })
42 return true
43 })
44}
45

Built with git-ssb-web