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