Commit 4879a173de93a45b824f4093ab59eafc12602a47
drafts: pass in location to compose() to support /public, /private and channels
Henry authored on 11/21/2017, 4:15:27 PMHenry committed on 11/24/2017, 1:52:28 AM
Parent: b89607c617cc8c160568ce8c7568788f55fe1732
Files changed
app/page/channel.js | changed |
app/page/private.js | changed |
app/page/public.js | changed |
message/html/compose.js | changed |
app/page/channel.js | ||
---|---|---|
@@ -38,9 +38,11 @@ | ||
38 | 38 … | { 'ev-click': toggleSubscription }, |
39 | 39 … | when(subscribed, 'Unsubscribe from channel', 'Subscribe to channel') |
40 | 40 … | ) |
41 | 41 … | |
42 | - const composer = api.message.html.compose({ meta: { type: 'post', channel: channelName } }) | |
42 … | + const composer = api.message.html.compose({ | |
43 … | + location: { page: '/channel' }, | |
44 … | + meta: { type: 'post', channel: channelName } }) | |
43 | 45 … | const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw) |
44 | 46 … | const { container, content } = api.app.html.scroller({ prepend: [subscribeButton, composer, filterMenu] }) |
45 | 47 … | |
46 | 48 … | function draw () { |
app/page/private.js | ||
---|---|---|
@@ -41,8 +41,9 @@ | ||
41 | 41 … | function privatePage (location) { |
42 | 42 … | const id = api.keys.sync.id() |
43 | 43 … | |
44 | 44 … | const composer = api.message.html.compose({ |
45 … | + location: { page: '/private' }, | |
45 | 46 … | meta: { type: 'post' }, |
46 | 47 … | prepublish: meta => { |
47 | 48 … | meta.recps = [id, ...(meta.mentions || [])] |
48 | 49 … | .filter(m => ref.isFeed(typeof m === 'string' ? m : m.link)) |
app/page/public.js | ||
---|---|---|
@@ -33,8 +33,9 @@ | ||
33 | 33 … | } |
34 | 34 … | |
35 | 35 … | function publicPage (location) { |
36 | 36 … | const composer = api.message.html.compose({ |
37 … | + location: { page: '/public' }, | |
37 | 38 … | meta: { type: 'post' }, |
38 | 39 … | placeholder: 'Write a public message' |
39 | 40 … | }) |
40 | 41 … | const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw) |
message/html/compose.js | ||
---|---|---|
@@ -18,9 +18,9 @@ | ||
18 | 18 … | |
19 | 19 … | exports.create = function (api) { |
20 | 20 … | return nest({ 'message.html.compose': compose }) |
21 | 21 … | |
22 | - function compose ({ shrink = true, meta, prepublish, placeholder = 'Write a message' }, cb) { | |
22 … | + function compose ({ location, shrink = true, meta, prepublish, placeholder = 'Write a message' }, cb) { | |
23 | 23 … | var files = [] |
24 | 24 … | var filesById = {} |
25 | 25 … | var channelInputFocused = Value(false) |
26 | 26 … | var textAreaFocused = Value(false) |
@@ -55,9 +55,13 @@ | ||
55 | 55 … | title: when(meta.channel, 'Reply is in same channel as original message') |
56 | 56 … | }) |
57 | 57 … | |
58 | 58 … | var draftPerstTimeout = null |
59 | - var draftLocation = resolve(meta).root || '/public' | |
59 … | + var draftLocation = resolve(meta).root | |
60 … | + if (!draftLocation) { | |
61 … | + draftLocation = location.page | |
62 … | + if (draftLocation === '/channel') draftLocation = draftLocation + ':' + meta.channel | |
63 … | + } | |
60 | 64 … | var textArea = h('textarea', { |
61 | 65 … | 'ev-input': () => { |
62 | 66 … | hasContent.set(!!textArea.value) |
63 | 67 … | clearTimeout(draftPerstTimeout) |
Built with git-ssb-web