git ssb

7+

dinoworm 🐛 / patchcore



Commit 3369d94cf2d91a92f0a8fc9fcc8e62b493c92792

display feed errors

Matt McKegg committed on 8/4/2018, 1:24:24 AM
Parent: cc5761a7888cf2028451fa4e3a4eedeadca0f595

Files changed

message/html/action/like.jschanged
message/html/action/like.jsView
@@ -1,5 +1,5 @@
1-var { h, computed, when } = require('mutant')
1 +var { h, computed, when, send } = require('mutant')
22 var nest = require('depnest')
33
44 exports.needs = nest({
55 'keys.sync.id': 'first',
@@ -9,23 +9,31 @@
99
1010 exports.gives = nest('message.html.action')
1111
1212 exports.create = (api) => {
13- return nest('message.html.action', function like (msg) {
13 + return nest('message.html.action', function (msg) {
1414 var id = api.keys.sync.id()
1515 var liked = computed([api.message.obs.likes(msg.key), id], doesLike)
1616 return when(liked,
1717 h('a.unlike', {
1818 href: '#',
19- 'ev-click': () => publishLike(msg, false)
19 + 'ev-click': send(unlike, msg)
2020 }, 'Unlike'),
2121 h('a.like', {
2222 href: '#',
23- 'ev-click': () => publishLike(msg, true)
23 + 'ev-click': send(like, msg)
2424 }, 'Like')
2525 )
2626 })
2727
28 + function like (msg) {
29 + publishLike(msg, true)
30 + }
31 +
32 + function unlike (msg) {
33 + publishLike(msg, false)
34 + }
35 +
2836 function publishLike (msg, status = true) {
2937 var like = status ? {
3038 type: 'vote',
3139 channel: msg.value.content.channel,
@@ -47,4 +55,5 @@
4755
4856 function doesLike (likes, userId) {
4957 return likes.includes(userId)
5058 }
59 +

Built with git-ssb-web