git ssb

10+

Matt McKegg / patchwork



Tree: 7e11036395d46d3c6fbcc56c03eef30bbba196be

Files: 7e11036395d46d3c6fbcc56c03eef30bbba196be / modules / invite / sheet.js

2176 bytesRaw
1var {h, when, Value, Proxy} = require('mutant')
2var nest = require('depnest')
3var electron = require('electron')
4
5exports.needs = nest({
6 'sheet.display': 'first',
7 'invite.async.accept': 'first'
8})
9
10exports.gives = nest('invite.sheet')
11
12exports.create = function (api) {
13 return nest('invite.sheet', function () {
14 api.sheet.display(close => {
15 var publishing = Value()
16 var publishStatus = Proxy()
17
18 var input = h('input', {
19 style: {
20 'font-size': '200%',
21 'margin-top': '20px',
22 'width': '100%'
23 },
24 placeholder: 'paste invite code here'
25 })
26 setTimeout(() => {
27 input.focus()
28 input.select()
29 }, 5)
30 return {
31 content: h('div', {
32 style: {
33 padding: '20px'
34 }
35 }, [
36 h('h2', {
37 style: {
38 'font-weight': 'normal'
39 }
40 }, ['By default, Patchwork will only see other users that are on the same local area network as you.']),
41 h('div', [
42 'In order to share with users on the internet, you need to be invited to a pub server.'
43 ]),
44 input
45 ]),
46 footer: [
47 h('button -save', {
48 disabled: publishing,
49 'ev-click': () => {
50 publishing.set(true)
51 publishStatus.set(api.invite.async.accept(input.value.trim(), (err) => {
52 if (err) {
53 publishing.set(false)
54 showDialog({
55 type: 'error',
56 title: 'Error',
57 buttons: ['OK'],
58 message: 'An error occurred while attempting to redeem invite.',
59 detail: err.message
60 })
61 } else {
62 close()
63 }
64 }))
65 }
66 }, [ when(publishing, publishStatus, 'Redeem Invite') ]),
67 h('button -cancel', {
68 'ev-click': close
69 }, 'Cancel')
70 ]
71 }
72 })
73 })
74}
75
76function showDialog (opts) {
77 electron.remote.dialog.showMessageBox(electron.remote.getCurrentWindow(), opts)
78}
79

Built with git-ssb-web