Files: a5f9e9c80b3948d0c40559bef2b6be37e82fcd6d / modules / message / async / publish.js
968 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 | return true |
41 | }) |
42 | } |
43 |
Built with git-ssb-web