Files: 1399cedf6a9c2dcf4b6662bdeb010225320af71c / app / page / threadNew.js
2976 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, Struct, Value, computed } = require('mutant') |
3 | |
4 | exports.gives = nest('app.page.threadNew') |
5 | |
6 | exports.needs = nest({ |
7 | 'about.html.image': 'first', |
8 | 'about.obs.name': 'first', |
9 | 'app.html.context': 'first', |
10 | 'app.html.thread': 'first', |
11 | 'history.sync.push': 'first', |
12 | 'keys.sync.id': 'first', |
13 | 'message.html.compose': 'first', |
14 | 'translations.sync.strings': 'first', |
15 | }) |
16 | |
17 | exports.create = (api) => { |
18 | |
19 | return nest('app.page.threadNew', threadNew) |
20 | |
21 | function threadNew (location) { |
22 | const { feed, channel } = location |
23 | |
24 | if (feed) return threadNewFeed(location) |
25 | // if (channel) return threadNewChannel(location) |
26 | } |
27 | |
28 | function threadNewFeed (location) { |
29 | const strings = api.translations.sync.strings() |
30 | |
31 | const { feed } = location |
32 | const name = api.about.obs.name(feed) |
33 | |
34 | const meta = Struct({ |
35 | type: 'post', |
36 | recps: [ |
37 | api.keys.sync.id(), |
38 | { link: feed, name } |
39 | ], |
40 | subject: Value() |
41 | }) |
42 | const composer = api.message.html.compose( |
43 | { meta, shrink: false }, |
44 | (err, msg) => api.history.sync.push(err ? err : Object.assign(msg, { feed })) |
45 | ) |
46 | |
47 | return h('Page -threadNew', {title: strings.threadNew.pageTitle}, [ |
48 | api.app.html.context(location), |
49 | h('div.content', [ |
50 | h('div.field -to', [ |
51 | h('div.label', strings.threadNew.field.to), |
52 | h('div.recps', [ |
53 | h('div.recp', [ |
54 | api.about.html.image(feed), |
55 | h('div.name', name) |
56 | ]) |
57 | ]) |
58 | ]), |
59 | h('div.field -subject', [ |
60 | h('div.label', strings.threadNew.field.subject), |
61 | h('input', { |
62 | 'ev-input': e => meta.subject.set(e.target.value), |
63 | placeholder: strings.optionalField |
64 | }), |
65 | ]), |
66 | composer |
67 | ]) |
68 | ]) |
69 | } |
70 | |
71 | // function threadNewChannel (location) { |
72 | // const strings = api.translations.sync.strings() |
73 | |
74 | // const { channel, flash } = location |
75 | |
76 | // const meta = Struct({ |
77 | // type: 'post', |
78 | // channel, |
79 | // subject: Value() |
80 | // }) |
81 | // const composer = api.message.html.compose( |
82 | // { meta, shrink: false }, |
83 | // (err, msg) => api.history.sync.push(err ? err : msg) |
84 | // ) |
85 | |
86 | // return h('Page -threadNew', {title: strings.threadNew.pageTitle}, [ |
87 | // h('div.content', [ |
88 | // flash ? h('div.flash', flash) : '', |
89 | // h('div.field -channel', [ |
90 | // h('div.label', strings.threadNew.field.channel), |
91 | // h('div.recps', [ |
92 | // h('div.recp', [ |
93 | // h('div.name', `#${channel}`) |
94 | // ]) |
95 | // ]) |
96 | // ]), |
97 | // h('div.field -subject', [ |
98 | // h('div.label', strings.threadNew.field.subject), |
99 | // h('input', { |
100 | // 'ev-input': e => meta.subject.set(e.target.value), |
101 | // placeholder: strings.optionalField |
102 | // }), |
103 | // ]), |
104 | // composer |
105 | // ]) |
106 | // ]) |
107 | // } |
108 | } |
109 | |
110 |
Built with git-ssb-web