git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 9bb4dd6572b0113dd462049c31d372b6062f9ac5

Files: 9bb4dd6572b0113dd462049c31d372b6062f9ac5 / modules / message / async / publish.js

952 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 })
41}
42

Built with git-ssb-web