From 606ff997bc4249d4ef0baae2e6336a739c3d64c7 Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 7 Mar 2017 13:19:25 -0500 Subject: Implement choosing ids for mentions --- lib/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/app.js') diff --git a/lib/app.js b/lib/app.js index d994d04..530f10f 100644 --- a/lib/app.js +++ b/lib/app.js @@ -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) }) } -- cgit v1.2.3