aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-04-18 02:37:10 -0700
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-04-18 20:08:13 -0700
commiteafabeace539c170554940859f678cbdea8db8cd (patch)
treee4c885b2b5bc68f079a8c2d9eac37003c96e70b7
parent9b2d69c5a6b691f6bdec12b08089ef104b889a50 (diff)
downloadpatchfoo-eafabeace539c170554940859f678cbdea8db8cd.tar.gz
patchfoo-eafabeace539c170554940859f678cbdea8db8cd.zip
Remove slow friend list
-rw-r--r--lib/app.js63
-rw-r--r--lib/serve.js42
2 files changed, 1 insertions, 104 deletions
diff --git a/lib/app.js b/lib/app.js
index 7424b50..d22e2b7 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -42,10 +42,6 @@ function App(sbot, config) {
this.unboxContent = memo({cache: lru(100)}, sbot.private.unbox)
this.reverseNameCache = lru(100)
- this.getFriendInfo = memo({cache: false}, this._getFriendInfo)
- this.getFollows = memo({cache: false}, this._getFollows)
- this.getFollowers = memo({cache: false}, this._getFollowers)
-
this.unboxMsg = this.unboxMsg.bind(this)
this.render = new Render(this, this.opts)
@@ -226,65 +222,6 @@ App.prototype.getFollow = function (source, dest, cb) {
)
}
-App.prototype._getFollows = function (id, cb) {
- var self = this
- pull(
- self.sbot.links({source: id, rel: 'contact', values: true}),
- pull.filter(function (msg) {
- var c = msg && msg.value && msg.value.content
- return c && c.type === 'contact' && msg.value.author === id
- }),
- pull.reduce(function (acc, msg) {
- var c = msg.value.content
- if (c.following) acc[c.contact] = true
- else delete acc[c.contact]
- return acc
- }, {}, cb)
- )
-}
-
-App.prototype._getFollowers = function (id, cb) {
- var self = this
- pull(
- self.sbot.links({dest: id, rel: 'contact', values: true}),
- pull.filter(function (msg) {
- var c = msg && msg.value && msg.value.content
- return c && c.type === 'contact' && c.contact === id
- }),
- pull.reduce(function (acc, msg) {
- var c = msg.value.content
- if (c.following) acc[msg.value.author] = true
- else delete acc[msg.value.author]
- return acc
- }, {}, cb)
- )
-}
-
-App.prototype._getFriendInfo = function (id, cb) {
- var self = this
- var done = multicb({pluck: 1, spread: true})
- self.getFollows(id, done())
- self.getFollowers(id, done())
- done(function (err, followsObj, followersObj) {
- if (err) return cb(err)
- var friends = []
- var follows = []
- var followers = []
- for (var k in followsObj) {
- if (followersObj[k]) friends.push(k)
- else follows.push(k)
- }
- for (var k in followersObj) {
- if (!followsObj[k]) followers.push(k)
- }
- cb(null, {
- friends: friends,
- follows: follows,
- followers: followers,
- })
- })
-}
-
App.prototype.unboxMessages = function () {
return pull(
paramap(this.unboxMsg, 16),
diff --git a/lib/serve.js b/lib/serve.js
index 754a67e..b87f304 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -829,33 +829,6 @@ Serve.prototype.wrapPage = function (title, searchQ) {
)
}
-Serve.prototype.renderFriend = function (id, cb) {
- var el = this.app.render.idLink(id, function (err) {
- cb(err, el)
- })
-}
-
-Serve.prototype.friendList = function (friends, cb) {
- var self = this
- var list = h('div')
- var first = true
- pull(
- pull.values(friends),
- paramap(function (id, cb) {
- self.renderFriend(id, function (err, el) {
- if (err) el = u.renderError(err, ext)
- cb(null, el)
- })
- }, 8),
- pull.drain(function (el) {
- if (first) first = false
- else list.appendChild(h('span', ', '))
- list.appendChild(el)
- }, cb)
- )
- return list
-}
-
var relationships = [
'',
'followed',
@@ -878,8 +851,7 @@ Serve.prototype.wrapUserFeed = function (isScrolled, id) {
self.app.getAbout(id, done())
self.app.getFollow(myId, id, done())
self.app.getFollow(id, myId, done())
- if (!isScrolled) self.app.getFriendInfo(id, done())
- done(function (err, about, weFollowThem, theyFollowUs, info) {
+ done(function (err, about, weFollowThem, theyFollowUs) {
if (err) return cb(err)
var relationshipI = weFollowThem | theyFollowUs<<1
var done = multicb({pluck: 1, spread: true})
@@ -906,18 +878,6 @@ Serve.prototype.wrapUserFeed = function (isScrolled, id) {
h('input', {type: 'submit',
value: relationshipActions[relationshipI]})
))
- ),
- h('tr',
- h('td', 'friends:'),
- h('td', self.friendList(info.friends, done()))
- ),
- h('tr',
- h('td', 'follows:'),
- h('td', self.friendList(info.follows, done()))
- ),
- h('tr',
- h('td', 'followers:'),
- h('td', self.friendList(info.followers, done()))
)
]
)),