From e0f8badf71a127ef2f66025af6c464abe512e8a4 Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 15 May 2017 13:08:31 -1000 Subject: Use own About implementation Use most popular about info instead of most recent. Slightly prefer a feed's own about info for itself. --- lib/app.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/app.js') 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) } -- cgit v1.2.3