Files: e5ad753b8414d998113f9305e0826f4cf1035fe4 / modules / message / async / publish.js
1100 bytesRaw
1 | var h = require('mutant/h') |
2 | var nest = require('depnest') |
3 | var i18n = require('i18n') |
4 | |
5 | var appRoot = require('app-root-path') |
6 | var i18n = require(appRoot + '/lib/i18n').i18n |
7 | |
8 | exports.needs = nest({ |
9 | 'sheet.display': 'first', |
10 | 'message.html.render': 'first', |
11 | 'sbot.async.publish': 'first', |
12 | 'keys.sync.id': 'first' |
13 | }) |
14 | |
15 | exports.gives = nest('message.async.publish') |
16 | |
17 | exports.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