Commit d0639ad38eaa9038c50046656e228137f3ac4aa8
Merge remote-tracking branch 'origin/master' into userFind
mix irving committed on 8/18/2017, 3:19:47 AMParent: f98c407e53e9a0b812757db574e4a35fcff143d4
Parent: 6b1478bdfa54da8cc7d272b584f5ff2fcb5a76cc
Files changed
app/html/header.mcss | changed |
app/page/channel.js | changed |
app/page/page.mcss | changed |
app/page/threadNew.js | changed |
message/html/compose.js | changed |
router/sync/routes.js | changed |
translations/sync.js | changed |
app/html/header.mcss | ||
---|---|---|
@@ -1,7 +1,5 @@ | ||
1 | 1 | Header { |
2 | - margin: 1rem 0 0 1rem | |
3 | - | |
4 | 2 | nav { |
5 | 3 | $navFA |
6 | 4 | padding: 1rem 0 |
7 | 5 |
app/page/channel.js | ||
---|---|---|
@@ -6,8 +6,9 @@ | ||
6 | 6 | |
7 | 7 | exports.gives = nest('app.page.channel') |
8 | 8 | |
9 | 9 | exports.needs = nest({ |
10 | + 'app.html.link': 'first', | |
10 | 11 | 'app.html.threadCard': 'first', |
11 | 12 | 'history.sync.push': 'first', |
12 | 13 | 'state.obs.channel': 'first', |
13 | 14 | 'translations.sync.strings': 'first', |
@@ -47,9 +48,12 @@ | ||
47 | 48 | return updates |
48 | 49 | } |
49 | 50 | ) |
50 | 51 | |
51 | - return h('Page -home', {title: location.channel}, [ | |
52 | + const Link = api.app.html.link | |
53 | + | |
54 | + return h('Page -home', {title: channel}, [ | |
55 | + Link({ page: 'threadNew', channel }, h('Button -primary', strings.channel.action.newThread)), | |
52 | 56 | h('div.container', [ threadsHtmlObs ]), |
53 | 57 | h('Button -showMore', { |
54 | 58 | 'ev-click': threadsHtmlObs.more, |
55 | 59 | disabled: disableShowMore |
app/page/page.mcss | ||
---|---|---|
@@ -1,13 +1,13 @@ | ||
1 | 1 | Page { |
2 | 2 | $backgroundPrimary |
3 | + margin-top: 4rem | |
3 | 4 | |
4 | 5 | div.container { |
5 | 6 | $maxWidth |
6 | 7 | min-height: 100vh |
7 | 8 | padding: 1rem |
8 | 9 | margin: 0 auto |
9 | - margin-top: 4rem | |
10 | 10 | |
11 | 11 | div.Thread { |
12 | 12 | margin-bottom: 1rem |
13 | 13 | } |
app/page/threadNew.js | ||
---|---|---|
@@ -17,9 +17,17 @@ | ||
17 | 17 | |
18 | 18 | return nest('app.page.threadNew', threadNew) |
19 | 19 | |
20 | 20 | function threadNew (location) { |
21 | + const { feed, channel } = location | |
22 | + | |
23 | + if (feed) return threadNewFeed(location) | |
24 | + if (channel) return threadNewChannel(location) | |
25 | + } | |
26 | + | |
27 | + function threadNewFeed (location) { | |
21 | 28 | const strings = api.translations.sync.strings() |
29 | + | |
22 | 30 | const { feed } = location |
23 | 31 | const name = api.about.obs.name(feed) |
24 | 32 | |
25 | 33 | const meta = Struct({ |
@@ -56,9 +64,43 @@ | ||
56 | 64 | composer |
57 | 65 | ]) |
58 | 66 | ]) |
59 | 67 | } |
60 | -} | |
61 | 68 | |
69 | + function threadNewChannel (location) { | |
70 | + const strings = api.translations.sync.strings() | |
62 | 71 | |
72 | + const { channel } = location | |
63 | 73 | |
74 | + const meta = Struct({ | |
75 | + type: 'post', | |
76 | + channel, | |
77 | + subject: Value() | |
78 | + }) | |
79 | + const composer = api.message.html.compose( | |
80 | + { meta, shrink: false }, | |
81 | + (err, msg) => api.history.sync.push(err ? err : msg) | |
82 | + ) | |
64 | 83 | |
84 | + return h('Page -threadNew', {title: strings.threadNew.pageTitle}, [ | |
85 | + h('div.container', [ | |
86 | + h('div.field -channel', [ | |
87 | + h('div.label', strings.threadNew.field.channel), | |
88 | + h('div.recps', [ | |
89 | + h('div.recp', [ | |
90 | + h('div.name', `#${channel}`) | |
91 | + ]) | |
92 | + ]) | |
93 | + ]), | |
94 | + h('div.field -subject', [ | |
95 | + h('div.label', strings.threadNew.field.subject), | |
96 | + h('input', { | |
97 | + 'ev-input': e => meta.subject.set(e.target.value), | |
98 | + placeholder: strings.optionalField | |
99 | + }), | |
100 | + ]), | |
101 | + composer | |
102 | + ]) | |
103 | + ]) | |
104 | + } | |
105 | +} | |
106 | + |
message/html/compose.js | ||
---|---|---|
@@ -171,8 +171,10 @@ | ||
171 | 171 | publishBtn.disabled = false |
172 | 172 | handleErr(err) |
173 | 173 | } |
174 | 174 | |
175 | + debugger | |
176 | + | |
175 | 177 | return api.message.async.publish(content, done) |
176 | 178 | // return api.message.html.confirm(content, done) |
177 | 179 | |
178 | 180 | function done (err, msg) { |
router/sync/routes.js | ||
---|---|---|
@@ -23,13 +23,8 @@ | ||
23 | 23 | const pages = api.app.page |
24 | 24 | // route format: [ routeValidator, routeFunction ] |
25 | 25 | |
26 | 26 | const routes = [ |
27 | - [ location => isBlob(location.blob), pages.image ], | |
28 | - [ location => location.page === 'home', pages.home ], | |
29 | - [ location => location.channel , pages.channel ], | |
30 | - [ location => location.page === 'settings', pages.settings ], | |
31 | - | |
32 | 27 | // Group pages |
33 | 28 | [ location => location.page === 'groupFind', pages.groupFind ], |
34 | 29 | [ location => location.page === 'groupIndex', pages.groupIndex ], |
35 | 30 | [ location => location.page === 'groupNew', pages.groupNew ], |
@@ -37,20 +32,24 @@ | ||
37 | 32 | |
38 | 33 | // Thread pages |
39 | 34 | // QUESTION - should this be for private threads + group threads? |
40 | 35 | [ location => location.page === 'threadNew' && isFeed(location.feed), pages.threadNew ], |
36 | + [ location => location.page === 'threadNew' && location.channel, pages.threadNew ], | |
41 | 37 | [ location => isMsg(location.key), pages.threadShow ], |
42 | 38 | |
43 | 39 | // User pages |
44 | 40 | [ location => location.page === 'userFind', pages.userFind ], |
45 | 41 | [ location => isFeed(location.feed), pages.userShow ], |
46 | 42 | |
43 | + [ location => location.page === 'home', pages.home ], | |
44 | + [ location => location.page === 'settings', pages.settings ], | |
45 | + [ location => isBlob(location.blob), pages.image ], | |
46 | + [ location => location.channel , pages.channel ], | |
47 | + | |
47 | 48 | // Error page |
48 | 49 | [ location => true, pages.error ] |
49 | 50 | ] |
50 | 51 | |
51 | 52 | return [...routes, ...sofar] |
52 | 53 | }) |
53 | 54 | } |
54 | 55 | |
55 | - | |
56 | - |
translations/sync.js | ||
---|---|---|
@@ -10,9 +10,13 @@ | ||
10 | 10 | loading: 'Loading...', |
11 | 11 | optionalField: 'optional', |
12 | 12 | sendMessage: 'Send', |
13 | 13 | showMore: 'Show More', |
14 | - channels: 'Channels', | |
14 | + channel: { | |
15 | + action: { | |
16 | + newThread: 'New thread' | |
17 | + } | |
18 | + }, | |
15 | 19 | directMessages: 'Direct Messages', |
16 | 20 | home: "Home", |
17 | 21 | error: "Error", |
18 | 22 | errorNotFound: "The page wasn't found", |
@@ -25,9 +29,10 @@ | ||
25 | 29 | threadNew: { |
26 | 30 | pageTitle: 'New Thread', |
27 | 31 | field: { |
28 | 32 | to: 'To', |
29 | - subject: 'Subject' | |
33 | + subject: 'Subject', | |
34 | + channel: 'Channel' | |
30 | 35 | } |
31 | 36 | |
32 | 37 | }, |
33 | 38 | threadShow: 'Direct Messages', |
Built with git-ssb-web