git ssb

16+

Dominic / patchbay



Commit bd939d096e931505332ac225cb144fe1704ca32d

Add unsubscribe and handle state change

Anders Rune Jensen committed on 9/13/2017, 10:39:58 PM
Parent: aa1f52e836a9f4a9cbdaec21c76521368b9ba070

Files changed

app/page/channel.jschanged
app/page/channel.jsView
@@ -25,18 +25,36 @@
2525 const channelName = channel.substr(1)
2626
2727 var subscribed = api.channel.obs.subscribed(api.keys.sync.id())
2828
29- function subscribeToChannel() {
29 + function subscribeToChannel(btn) {
30 + btn.target.replaceWith(unsubscribeButton())
3031 api.sbot.async.publish({
3132 type: 'channel',
3233 channel: channelName,
3334 subscribed: true
3435 })
3536 }
3637
37- const channelHeader = h('header', [channel, h('span', subscribed.has(channelName)() ? ' is subscribed' : h('button', { 'ev-click': subscribeToChannel }, 'Subscribe'))])
38 + function unsubscribeFromChannel(btn) {
39 + btn.target.replaceWith(subscribeButton())
40 + api.sbot.async.publish({
41 + type: 'channel',
42 + channel: channelName,
43 + subscribed: false
44 + })
45 + }
3846
47 + function unsubscribeButton() {
48 + return h('button', { 'ev-click': unsubscribeFromChannel }, 'Unsubscribe from channel')
49 + }
50 +
51 + function subscribeButton() {
52 + return h('button', { 'ev-click': subscribeToChannel }, 'Subscribe to channel')
53 + }
54 +
55 + const channelHeader = h('span', subscribed.has(channelName)() ? unsubscribeButton() : subscribeButton())
56 +
3957 const composer = api.message.html.compose({ meta: { type: 'post', channel: channelName } })
4058 const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw)
4159 const { container, content } = api.app.html.scroller({ prepend: [composer, filterMenu, channelHeader] })
4260

Built with git-ssb-web