Commit bd939d096e931505332ac225cb144fe1704ca32d
Add unsubscribe and handle state change
Anders Rune Jensen committed on 9/13/2017, 10:39:58 PMParent: aa1f52e836a9f4a9cbdaec21c76521368b9ba070
Files changed
app/page/channel.js | changed |
app/page/channel.js | |||
---|---|---|---|
@@ -25,18 +25,36 @@ | |||
25 | 25 … | const channelName = channel.substr(1) | |
26 | 26 … | ||
27 | 27 … | var subscribed = api.channel.obs.subscribed(api.keys.sync.id()) | |
28 | 28 … | ||
29 | - function subscribeToChannel() { | ||
29 … | + function subscribeToChannel(btn) { | ||
30 … | + btn.target.replaceWith(unsubscribeButton()) | ||
30 | 31 … | api.sbot.async.publish({ | |
31 | 32 … | type: 'channel', | |
32 | 33 … | channel: channelName, | |
33 | 34 … | subscribed: true | |
34 | 35 … | }) | |
35 | 36 … | } | |
36 | 37 … | ||
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 … | + } | ||
38 | 46 … | ||
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 … | + | ||
39 | 57 … | const composer = api.message.html.compose({ meta: { type: 'post', channel: channelName } }) | |
40 | 58 … | const { filterMenu, filterDownThrough, filterUpThrough, resetFeed } = api.app.html.filter(draw) | |
41 | 59 … | const { container, content } = api.app.html.scroller({ prepend: [composer, filterMenu, channelHeader] }) | |
42 | 60 … |
Built with git-ssb-web