aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-15 13:08:31 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-15 13:08:31 -1000
commite0f8badf71a127ef2f66025af6c464abe512e8a4 (patch)
tree577de8c1881f348ebd7ed2a62aea6f4de7d6cb28 /lib/app.js
parent58b40d18c7d49ef071ece70af5e6d9e1d12301e2 (diff)
downloadpatchfoo-e0f8badf71a127ef2f66025af6c464abe512e8a4.tar.gz
patchfoo-e0f8badf71a127ef2f66025af6c464abe512e8a4.zip
Use own About implementation
Use most popular about info instead of most recent. Slightly prefer a feed's own about info for itself.
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/app.js b/lib/app.js
index dfec6bd..eee6c95 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -4,7 +4,6 @@ var lru = require('hashlru')
var pkg = require('../package')
var u = require('./util')
var pull = require('pull-stream')
-var ssbAvatar = require('ssb-avatar')
var hasher = require('pull-hash/ext/ssb')
var multicb = require('multicb')
var paramap = require('pull-paramap')
@@ -32,9 +31,10 @@ function App(sbot, config) {
}
sbot.get = memo({cache: lru(100)}, sbot.get)
+ this.about = new About(this, sbot.id)
this.getMsg = memo({cache: lru(100)}, getMsgWithValue, sbot)
this.getAbout = memo({cache: this.aboutCache = lru(500)},
- getAbout.bind(this), sbot, sbot.id)
+ this._getAbout.bind(this))
this.unboxContent = memo({cache: lru(100)}, sbot.private.unbox)
this.reverseNameCache = lru(100)
@@ -199,11 +199,12 @@ function getMsgWithValue(sbot, id, cb) {
})
}
-function getAbout(sbot, src, id, cb) {
+App.prototype._getAbout = function (id, cb) {
var self = this
- ssbAvatar(sbot, src, id, function (err, about) {
+ if (!u.isRef(id)) return cb(null, {})
+ self.about.get(id, function (err, about) {
if (err) return cb(err)
- var sigil = id && id[0] || '@'
+ var sigil = id[0] || '@'
if (about.name && about.name[0] !== sigil) {
about.name = sigil + about.name
}
@@ -212,6 +213,10 @@ function getAbout(sbot, src, id, cb) {
})
}
+App.prototype.pullGetMsg = function (id) {
+ return pull.asyncMap(this.getMsg)(pull.once(id))
+}
+
App.prototype.createLogStream = function (opts) {
opts = opts || {}
return opts.sortByTimestamp
@@ -321,5 +326,5 @@ App.prototype.createContactStreams = function (id) {
}
App.prototype.createAboutStreams = function (id) {
- return new About(this.sbot).createAboutStreams(id)
+ return this.about.createAboutStreams(id)
}