Commit 288090456f797459713cd94143110c26816cf1a3
render the proper star/unstar if message has already been starred or unstarred
Ev Bogue committed on 6/2/2018, 5:53:17 PMParent: 8311621405027acca27d723deb46b8a202575b94
Files changed
tools.js | changed |
tools.js | ||
---|---|---|
@@ -45,21 +45,28 @@ | ||
45 | 45 | } |
46 | 46 | ) |
47 | 47 | |
48 | 48 | votebutton.appendChild(star) |
49 | - /*if (votebutton) { | |
50 | - if (votebutton.firstChild) { | |
51 | - console.log(votebutton.firstChild) | |
52 | - votebutton.removeChild(votebutton.firstChild) | |
53 | - } | |
54 | - if (msg.value.content.passedVote) { | |
55 | - console.log(msg.value.content.passedVote) | |
56 | - if (msg.value.content.passedVote == 1) { | |
57 | - votebutton.appendChild(unstar) | |
58 | - } else { votebutton.appendChild(star) } | |
59 | - } else { | |
60 | - } | |
61 | - }*/ | |
49 | + | |
50 | + pull( | |
51 | + sbot.links({rel: 'vote', dest: msg.key, live: true}), | |
52 | + pull.drain(function (link) { | |
53 | + console.log(link) | |
54 | + if (link.key) { | |
55 | + sbot.get(link.key, function (err, data) { | |
56 | + if (err) throw err | |
57 | + if (data.author == id) { | |
58 | + console.log(data) | |
59 | + if (data.content.vote.value == 1) | |
60 | + votebutton.replaceChild(unstar, star) | |
61 | + if (data.content.vote.value == -1) | |
62 | + votebutton.replaceChild(star, unstar) | |
63 | + } | |
64 | + }) | |
65 | + } | |
66 | + }) | |
67 | + ) | |
68 | + | |
62 | 69 | return votebutton |
63 | 70 | } |
64 | 71 | |
65 | 72 | function votes (msg) { |
@@ -70,12 +77,8 @@ | ||
70 | 77 | pull.drain(function (link) { |
71 | 78 | if (link.key) { |
72 | 79 | sbot.get(link.key, function (err, data) { |
73 | 80 | if (err) throw err |
74 | - if (data.author == id) { | |
75 | - msg.value.content.passedVote = data.content.vote.value | |
76 | - exports.star(msg) | |
77 | - } | |
78 | 81 | if (data.content.vote.value == 1) { |
79 | 82 | if (localStorage[data.author + 'name']) |
80 | 83 | name = localStorage[data.author + 'name'] |
81 | 84 | else |
Built with git-ssb-web