git ssb

16+

cel / patchfoo



Commit 29f56c3e49c767f75164f57ccd1ac52b389794c0

Optimize looking up follow

cel committed on 5/10/2017, 5:44:37 AM
Parent: 11e894c5c9efbc6ee141f614eea3a328517aee5b

Files changed

lib/app.jschanged
lib/app.jsView
@@ -249,17 +249,19 @@
249249
250250 App.prototype.getFollow = function (source, dest, cb) {
251251 var self = this
252252 pull(
253- self.sbot.links({source: source, dest: dest, rel: 'contact', values: true}),
254- pull.filter(function (msg) {
255- var c = msg && msg.value && msg.value.content
253 + self.sbot.links({source: source, dest: dest, rel: 'contact', reverse: true,
254 + values: true, meta: false, keys: false}),
255 + pull.filter(function (value) {
256 + var c = value && value.content
256257 return c && c.type === 'contact'
257258 }),
258- pull.reduce(function (doesFollow, msg) {
259- var c = msg.value.content
260- return !!c.following
261- }, false, cb)
259 + pull.take(1),
260 + pull.collect(function (err, msgs) {
261 + if (err) return cb(err)
262 + cb(null, msgs[0] && !!msgs[0].content.following)
263 + })
262264 )
263265 }
264266
265267 App.prototype.unboxMessages = function () {

Built with git-ssb-web