git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit e03e2bdee5572f15fe3434f5b1e0d456f6bd0f76

testing speed between different follow count renders

Ev Bogue committed on 6/16/2018, 8:55:18 PM
Parent: d72f1769d24688deeb9c8305757bc31331906b03

Files changed

tools.jschanged
tools.jsView
@@ -13,10 +13,43 @@
1313
1414 var id = require('./keys').id
1515
1616 module.exports.getFollowing = function (src) {
17- var count = 0
17+ var followingCount = 0
1818
19+ var following = h('div.following', 'Following: ')
20+
21+ following.appendChild(h('span#followingcount', '0'))
22+ following.appendChild(h('br'))
23+
24+ pull(
25+ sbot.query({query: [{$filter: { value: { author: src, content: {type: 'contact'}}}}], live: true}),
26+ pull.drain(function (msg) {
27+ if (msg.value) {
28+ if (msg.value.content.following == true) {
29+ followingcount = document.getElementById('followingcount')
30+ followingCount++
31+ followingcount.textContent = followingCount
32+ var gotIt = document.getElementById('following:' + msg.value.content.contact.substring(0, 44))
33+ if (gotIt == null) {
34+ following.appendChild(h('a#following:'+ msg.value.content.contact.substring(0, 44), {title: avatar.name(msg.value.content.contact).textContent, href: '#' + msg.value.content.contact}, h('span.avatar--small', avatar.image(msg.value.content.contact))))
35+ }
36+ }
37+ if (msg.value.content.following == false) {
38+ followingcount = document.getElementById('followingcount')
39+ followingCount--
40+ followingcount.textContent = followingCount
41+ var gotIt = document.getElementById('following:' + msg.value.content.contact.substring(0, 44))
42+ if (gotIt != null) {
43+ gotIt.outerHTML = ''
44+ }
45+ }
46+ }
47+ })
48+ )
49+ return following
50+/* var count = 0
51+
1952 var following = h('div.following')
2053
2154 following.appendChild(h('span', 'Following: ' + count))
2255 following.appendChild(h('br'))
@@ -32,14 +65,50 @@
3265 }
3366 })
3467
3568 return following
36-
69+*/
3770 }
3871
3972 module.exports.getFollowers = function (src) {
40- var count = 0
73+ var followerCount = 0
4174
75+ var followers = h('div.followers', 'Followers: ')
76+
77+ followers.appendChild(h('span#followercount', '0'))
78+ followers.appendChild(h('br'))
79+
80+ pull(
81+ sbot.query({query: [{$filter: { value: { content: {type: 'contact', contact: src}}}}], live: true}),
82+ pull.drain(function (msg) {
83+ if (msg.value) {
84+ if (msg.value.content.following == true) {
85+ followcount = document.getElementById('followercount')
86+ followerCount++
87+ followcount.textContent = followerCount
88+ var gotIt = document.getElementById('followers:' + msg.value.author.substring(0, 44))
89+ if (gotIt == null) {
90+ followers.appendChild(h('a#followers:'+ msg.value.author.substring(0, 44), {title: avatar.name(msg.value.author).textContent, href: '#' + msg.value.author}, h('span.avatar--small', avatar.image(msg.value.author))))
91+ }
92+ }
93+ if (msg.value.content.following == false) {
94+ followcount = document.getElementById('followercount')
95+ followerCount--
96+ followcount.textContent = followerCount
97+ var gotIt = document.getElementById('followers:' + msg.value.author.substring(0, 44))
98+ if (gotIt != null) {
99+ gotIt.outerHTML = ''
100+ }
101+ }
102+ }
103+ })
104+ )
105+
106+ return followers
107+
108+
109+ /*var count = 0
110+
42111 var followers = h('div.followers')
43112
44113 followers.appendChild(h('span', 'Followers: ' + count))
45114 followers.appendChild(h('br'))
@@ -56,15 +125,15 @@
56125 }
57126 })
58127
59128
60- return followers
129+ return followers*/
61130 }
62131
63132 module.exports.follow = function (src) {
64133 var button = h('span.button')
65134
66- var followButton = h('button.btn', 'Follow ' + avatar.name(src).textContent, {
135+ var followButton = h('button.btn', 'Follow ', avatar.name(src), {
67136 onclick: function () {
68137 var content = {
69138 type: 'contact',
70139 contact: src,
@@ -76,9 +145,9 @@
76145 })
77146 }
78147 })
79148
80- var unfollowButton = h('button.btn', 'Unfollow ' + avatar.name(src).textContent, {
149+ var unfollowButton = h('button.btn', 'Unfollow ', avatar.name(src), {
81150 onclick: function () {
82151 var content = {
83152 type: 'contact',
84153 contact: src,

Built with git-ssb-web