git ssb

2+

ev / mvd



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 PM
Parent: 8311621405027acca27d723deb46b8a202575b94

Files changed

tools.jschanged
tools.jsView
@@ -45,21 +45,28 @@
4545 }
4646 )
4747
4848 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 +
6269 return votebutton
6370 }
6471
6572 function votes (msg) {
@@ -70,12 +77,8 @@
7077 pull.drain(function (link) {
7178 if (link.key) {
7279 sbot.get(link.key, function (err, data) {
7380 if (err) throw err
74- if (data.author == id) {
75- msg.value.content.passedVote = data.content.vote.value
76- exports.star(msg)
77- }
7881 if (data.content.vote.value == 1) {
7982 if (localStorage[data.author + 'name'])
8083 name = localStorage[data.author + 'name']
8184 else

Built with git-ssb-web