git ssb

10+

Matt McKegg / patchwork



Tree: d245481b81b4075ba2a29823d0441ec941545a32

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

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

Built with git-ssb-web