diff options
Diffstat (limited to 'lib/app.js')
-rw-r--r-- | lib/app.js | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -31,8 +31,9 @@ function App(sbot, config) { sbot.get = memo({cache: lru(100)}, sbot.get) this.getMsg = memo({cache: lru(100)}, getMsgWithValue, sbot) - this.getAbout = memo({cache: lru(100)}, getAbout, sbot, sbot.id) + this.getAbout = memo({cache: lru(100)}, getAbout.bind(this), sbot, sbot.id) this.unboxContent = memo({cache: lru(100)}, sbot.private.unbox) + this.reverseNameCache = lru(100) this.unboxMsg = this.unboxMsg.bind(this) @@ -110,9 +111,15 @@ App.prototype.addBlob = function (cb) { } App.prototype.pushBlob = function (id, cb) { + console.error('pushing blob', id) this.sbot.blobs.push(id, cb) } +App.prototype.getReverseNameSync = function (name) { + var id = this.reverseNameCache.get(name) + return id +} + function getMsgWithValue(sbot, id, cb) { sbot.get(id, function (err, value) { if (err) return cb(err) @@ -121,12 +128,14 @@ function getMsgWithValue(sbot, id, cb) { } function getAbout(sbot, src, id, cb) { + var self = this ssbAvatar(sbot, src, id, function (err, about) { if (err) return cb(err) var sigil = id && id[0] || '@' if (about.name && about.name[0] !== sigil) { about.name = sigil + about.name } + self.reverseNameCache.set(about.name, id) cb(null, about) }) } |