git ssb

10+

Matt McKegg / patchwork



Tree: a475db3f08d588ebb0617a26b471e10e3a586a16

Files: a475db3f08d588ebb0617a26b471e10e3a586a16 / modules / message / sheet / preview.js

1730 bytesRaw
1var h = require('mutant/h')
2var nest = require('depnest')
3var when = require('mutant/when')
4
5exports.needs = nest({
6 'sheet.display': 'first',
7 'message.html.render': 'first',
8 'intl.sync.i18n': 'first',
9 'emoji.sync.url': 'first'
10})
11
12exports.gives = nest('message.sheet.preview')
13
14exports.create = function (api) {
15 const i18n = api.intl.sync.i18n
16 return nest('message.sheet.preview', function (msg, cb) {
17 api.sheet.display(function (close) {
18 var isPrivate = msg.value.private
19 var isRoot = !msg.value.content.root
20 return {
21 content: [
22 api.message.html.render(msg)
23 ],
24 footer: [
25 when(isPrivate,
26 h('img', {src: api.emoji.sync.url('closed_lock_with_key')}),
27 h('img', {src: api.emoji.sync.url('globe_with_meridians')})
28 ),
29 when(isPrivate,
30 h('div.info -private', [
31 when(isRoot,
32 i18n('Only visible to you and people that have been mentioned'),
33 i18n('Only visible to you and other thread participants')
34 )
35 ]),
36 h('div.info -public', [
37 when(msg.publicallyEditable,
38 i18n('This message will be public and can be edited by anyone'),
39 i18n('This message will be public and cannot be edited or deleted')
40 )
41 ])
42 ),
43 h('button -save', { 'ev-click': publish }, i18n('Confirm')),
44 h('button -cancel', { 'ev-click': cancel }, i18n('Cancel'))
45 ]
46 }
47
48 function publish () {
49 close()
50 cb(null, true)
51 }
52
53 function cancel () {
54 close()
55 cb(null, false)
56 }
57 })
58 return true
59 })
60}
61

Built with git-ssb-web