diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-03-07 13:19:25 -0500 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-03-08 12:08:59 -0500 |
commit | 606ff997bc4249d4ef0baae2e6336a739c3d64c7 (patch) | |
tree | bbede06b3e031a1a7718c8b6653ff48073a6e709 /lib/app.js | |
parent | 033d27ac3fe92dd16d9284aee9ad98f64e1c770b (diff) | |
download | patchfoo-606ff997bc4249d4ef0baae2e6336a739c3d64c7.tar.gz patchfoo-606ff997bc4249d4ef0baae2e6336a739c3d64c7.zip |
Implement choosing ids for mentions
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) }) } |