Files: 0bc52a13a9c729a0b10e7f1bc22d167d5945ce75 / modules / message / async / publish.js
952 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 | }) |
10 | |
11 | exports.gives = nest('message.async.publish') |
12 | |
13 | exports.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