git ssb

2+

mixmix / ticktack



Commit 8c68dbb9a3b69a0cf0e0dd503ef059a873189cd5

fix channel handling!

mix irving committed on 2/13/2018, 10:00:26 PM
Parent: dba1ec48c08d0594936b838fc855835948a3aef2

Files changed

app/page/blogIndex.mcsschanged
app/page/blogSearch.mcsschanged
app/page/channelShow.jschanged
app/page/channelShow.mcsschanged
background-process.jschanged
channel/async.jschanged
channel/html/subscribe.jschanged
channel/obs.jschanged
message/html/channel.jschanged
router/sync/routes.jschanged
app/page/blogIndex.mcssView
@@ -9,8 +9,12 @@
99 section.content {
1010 div.BlogCard {
1111 flex-basis: 100%
1212 border-bottom: 1px solid rgba(0,0,0, .1)
13 +
14 + :last-child {
15 + border-bottom: none
16 + }
1317 }
1418 }
1519
1620 section.bottom {
app/page/blogSearch.mcssView
@@ -47,8 +47,12 @@
4747 div.BlogCard {
4848 flex-basis: 100%
4949
5050 border-bottom: 1px solid gainsboro
51 +
52 + :last-child {
53 + border-bottom: none
54 + }
5155 }
5256 }
5357
5458 section.bottom {
app/page/channelShow.jsView
@@ -8,31 +8,29 @@
88 'app.html.sideNav': 'first',
99 'app.html.topNav': 'first',
1010 'app.html.scroller': 'first',
1111 'app.html.blogCard': 'first',
12 + 'channel.html.subscribe': 'first',
1213 'feed.pull.channel': 'first',
1314 'history.sync.push': 'first',
14- 'translations.sync.strings': 'first',
15- 'channel.obs.recent': 'first',
16- 'channel.html.subscribe': 'first'
15 + 'translations.sync.strings': 'first'
1716 })
1817
1918 exports.create = (api) => {
2019 return nest('app.page.channelShow', channelShow)
2120
2221 function channelShow(location) {
23- var strings = api.translations.sync.strings()
22 + const strings = api.translations.sync.strings()
23 + const { channel } = location
2424
25- var searchVal = resolve(location.channel)
26-
27- createStream = api.feed.pull.channel(location.channel)
25 + createStream = api.feed.pull.channel(channel)
2826
2927 const prepend = [
3028 api.app.html.topNav(location),
3129 h('section.about', [
32- h('h1', location.channel),
30 + h('h1', channel),
3331 h('div.actions', [
34- api.channel.html.subscribe(location.channel)
32 + api.channel.html.subscribe(channel)
3533 ])
3634 ]),
3735 ]
3836
@@ -54,8 +52,12 @@
5452 // updateBottom: updateRecentMsgCache,
5553 render
5654 })
5755
56 + location.page = location.page || 'channelShow'
57 + // covers case where router.sync.normalise delivers a loc = { channel: '#channelName' }
58 + // HACK: helps sideNav
59 +
5860 return h('Page -channelShow', { title: strings.home }, [
5961 api.app.html.sideNav(location),
6062 channelPosts
6163 ])
app/page/channelShow.mcssView
@@ -8,37 +8,34 @@
88 right: 0
99 top: 0
1010 z-index: 99
1111
12-
12 + padding-bottom: 1rem
13 + margin-bottom: 1rem
1314
1415 section.about {
15-
16 + padding-bottom: 1rem
17 +
1618 display: flex
1719 flex-direction: column
1820 align-items: center
19- padding-bottom: 1rem
20-
2121
2222 h1 {
2323 font-weight: bold
2424 font-size: 1.5rem
2525 padding: 1rem
2626
2727 margin: auto
28-
2928 }
3029
3130 div.actions {
3231 display: flex
3332
3433 div.Button {
3534 margin: auto
3635 }
37-
3836 }
3937 }
40-
4138 }
4239
4340 section.content {
4441 background-color: #fff
@@ -52,8 +49,12 @@
5249 div.BlogCard {
5350 flex-basis: 100%
5451
5552 border-bottom: 1px solid gainsboro
53 +
54 + :last-child {
55 + border-bottom: none
56 + }
5657 }
5758 }
5859
5960 section.bottom {
background-process.jsView
@@ -25,4 +25,5 @@
2525 var sbot = createSbot(config)
2626 var manifest = sbot.getManifest()
2727 fs.writeFileSync(Path.join(config.path, 'manifest.json'), JSON.stringify(manifest))
2828 electron.ipcRenderer.send('server-started')
29 +
channel/async.jsView
@@ -16,8 +16,9 @@
1616 'channel.async': {subscribe, unsubscribe}
1717 })
1818
1919 function subscribe (channel, cb) {
20 + channel = channel.replace(/^#/, '')
2021 if (!channel) throw new Error('a channel must be specified')
2122 api.sbot.async.publish({
2223 type: 'channel',
2324 channel: channel,
@@ -25,8 +26,9 @@
2526 }, cb)
2627 }
2728
2829 function unsubscribe (channel, cb) {
30 + channel = channel.replace(/^#/, '')
2931 if (!channel) throw new Error('a channel must be specified')
3032 api.sbot.async.publish({
3133 type: 'channel',
3234 channel: channel,
channel/html/subscribe.jsView
@@ -3,9 +3,8 @@
33
44 exports.gives = nest('channel.html.subscribe')
55
66 exports.needs = nest({
7- 'keys.sync.id': 'first',
87 'translations.sync.strings': 'first',
98 'channel.obs.isSubscribedTo': 'first',
109 'channel.async.subscribe': 'first',
1110 'channel.async.unsubscribe': 'first',
@@ -13,13 +12,18 @@
1312
1413 exports.create = function (api) {
1514
1615 return nest('channel.html.subscribe', (channel) => {
16 + channel = channel.replace(/^#/, '')
1717 const strings = api.translations.sync.strings()
18- const myId = api.keys.sync.id()
1918 const { subscribe, unsubscribe } = api.channel.async
20-
21- return when(api.channel.obs.isSubscribedTo(channel, myId),
19 + const isSubscribed = api.channel.obs.isSubscribedTo(channel)
20 +
21 + isSubscribed(val => {
22 + console.log(channel, 'subscribed:', val)
23 + })
24 +
25 + return when(isSubscribed,
2226 h('Button', { 'ev-click': () => unsubscribe(channel) }, strings.channelShow.action.unsubscribe),
2327 h('Button -primary', { 'ev-click': () => subscribe(channel) }, strings.channelShow.action.subscribe)
2428 )
2529 })
channel/obs.jsView
@@ -1,11 +1,12 @@
11 const nest = require('depnest')
22 const ref = require('ssb-ref')
3-const computed = require('mutant/computed')
3 +const { computed, onceTrue } = require('mutant')
44
55 exports.needs = nest({
66 'keys.sync.id': 'first',
77 'channel.obs.subscribed': 'first',
8 + 'sbot.obs.connection': 'first',
89 })
910
1011 exports.gives = nest('channel.obs.isSubscribedTo')
1112
@@ -15,13 +16,17 @@
1516
1617 return nest('channel.obs.isSubscribedTo', isSubscribedTo)
1718
1819 function isSubscribedTo (channel, id) {
20 + channel = channel.replace(/^#/, '')
1921 if (!ref.isFeed(id)) {
2022 id = getMyId()
2123 }
22-
23- return computed(getSubscriptions(id), (v) => v.has(channel))
24 +
25 + // TODO - use ssb-server-channel index to make a better subscribed obs
26 + return computed(getSubscriptions(id), set => {
27 + return set.has(channel)
28 + })
2429 }
2530
2631 //cache getters
2732
@@ -30,9 +35,9 @@
3035 return myId
3136 }
3237
3338 function getSubscriptions (id) {
34- if (!subscriptions[id]) subscriptions[id] = api.channel.obs.subscribed(id)
39 + if (subscriptions[id] === undefined) subscriptions[id] = api.channel.obs.subscribed(id)
3540 return subscriptions[id]
3641 }
3742 }
3843
message/html/channel.jsView
@@ -10,17 +10,18 @@
1010 exports.create = function (api) {
1111 return nest('message.html.channel', channel)
1212
1313 function channel (msgOrChannel, opts = {} ) {
14- const channel = typeof msgOrChannel === 'string'
14 + var channel= typeof msgOrChannel === 'string'
1515 ? msgOrChannel
1616 : msgOrChannel.value.content.channel
17 + channel = channel.replace(/^#/ , '')
1718
1819 if (!channel) return
1920
2021 const {
2122 classList = [],
22- location = { page: 'blogSearch', channel }
23 + location = { page: 'channelShow', channel }
2324 } = opts
2425
2526 const goToChannel = (e) => {
2627 e.stopPropagation()
router/sync/routes.jsView
@@ -52,10 +52,10 @@
5252
5353 // Channel related pages
5454 [ location => location.page === 'channelSubscriptions', pages.channelSubscriptions],
5555 [ location => location.page === 'channelShow', pages.channelShow ],
56 + [ location => location.channel, pages.channelShow ],
5657
57-
5858 // AddressBook pages
5959 [ location => location.page === 'addressBook', pages.addressBook ],
6060
6161 // Private Thread pages

Built with git-ssb-web