Files: 0b8fb446132852847a9ccb4a0a3204f20e6d3c1a / modules / message / async / publish.js
1043 bytesRaw
1 | var h = require('mutant/h') |
2 | var nest = require('depnest') |
3 | |
4 | exports.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 | |
12 | exports.gives = nest('message.async.publish') |
13 | |
14 | exports.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