aboutsummaryrefslogtreecommitdiff
path: root/lib/app.js
diff options
context:
space:
mode:
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)
}