git ssb

16+

Dominic / patchbay



Commit 4879a173de93a45b824f4093ab59eafc12602a47

drafts: pass in location to compose() to support /public, /private and channels

Henry authored on 11/21/2017, 4:15:27 PM
Henry committed on 11/24/2017, 1:52:28 AM
Parent: b89607c617cc8c160568ce8c7568788f55fe1732

Files changed

app/page/channel.jschanged
app/page/private.jschanged
app/page/public.jschanged
message/html/compose.jschanged
app/page/channel.jsView
@@ -38,9 +38,11 @@
3838 { 'ev-click': toggleSubscription },
3939 when(subscribed, 'Unsubscribe from channel', 'Subscribe to channel')
4040 )
4141
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 } })
4345 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
4446 const { container, content } = api.app.html.scroller({ prepend: [subscribeButton, composer, filterMenu] })
4547
4648 function draw () {
app/page/private.jsView
@@ -41,8 +41,9 @@
4141 function privatePage (location) {
4242 const id = api.keys.sync.id()
4343
4444 const composer = api.message.html.compose({
45 + location: { page: '/private' },
4546 meta: { type: 'post' },
4647 prepublish: meta => {
4748 meta.recps = [id, ...(meta.mentions || [])]
4849 .filter(m => ref.isFeed(typeof m === 'string' ? m : m.link))
app/page/public.jsView
@@ -33,8 +33,9 @@
3333 }
3434
3535 function publicPage (location) {
3636 const composer = api.message.html.compose({
37 + location: { page: '/public' },
3738 meta: { type: 'post' },
3839 placeholder: 'Write a public message'
3940 })
4041 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
message/html/compose.jsView
@@ -18,9 +18,9 @@
1818
1919 exports.create = function (api) {
2020 return nest({ 'message.html.compose': compose })
2121
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) {
2323 var files = []
2424 var filesById = {}
2525 var channelInputFocused = Value(false)
2626 var textAreaFocused = Value(false)
@@ -55,9 +55,13 @@
5555 title: when(meta.channel, 'Reply is in same channel as original message')
5656 })
5757
5858 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 + }
6064 var textArea = h('textarea', {
6165 'ev-input': () => {
6266 hasContent.set(!!textArea.value)
6367 clearTimeout(draftPerstTimeout)

Built with git-ssb-web