From 2473135971009a727894d210dab0da72569f61a8 Mon Sep 17 00:00:00 2001 From: cel Date: Wed, 27 Dec 2017 12:14:31 -1000 Subject: Fix detecting ssb-ooo when patchfoo is loaded as a plugin before it --- lib/app.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/app.js b/lib/app.js index 81f58f5..2606067 100644 --- a/lib/app.js +++ b/lib/app.js @@ -47,9 +47,7 @@ function App(sbot, config) { this.about = new About(this, sbot.id) this.msgCache = lru(100) this.getMsg = memo({cache: this.msgCache}, getMsgWithValue, sbot) - this.getMsgOoo = sbot.ooo - ? memo({cache: this.msgCache}, sbot.ooo.get) - : function (id, cb) { cb(new Error('missing ssb-ooo plugin')) } + this.getMsgOoo = memo({cache: this.msgCache}, this.getMsgOoo) this.getAbout = memo({cache: this.aboutCache = lru(500)}, this._getAbout.bind(this)) this.unboxContent = memo({cache: lru(100)}, sbot.private.unbox) @@ -184,6 +182,12 @@ App.prototype.getMsgDecrypted = function (key, cb) { }) } +App.prototype.getMsgOoo = function (key, cb) { + var ooo = this.sbot.ooo + if (!ooo) return cb(new Error('missing ssb-ooo plugin')) + ooo.get(key, cb) +} + App.prototype.getMsgDecryptedOoo = function (key, cb) { var self = this this.getMsgOoo(key, function (err, msg) { @@ -346,16 +350,6 @@ function getMsgWithValue(sbot, id, cb) { }) } -function getMsgOooWithValueCreate(sbot) { - if (!sbot.ooo) { - var err = new Error('missing ssb-ooo plugin') - return function (id, cb) { - cb(null, err) - } - } - return sbot.ooo.get -} - App.prototype._getAbout = function (id, cb) { var self = this if (!u.isRef(id)) return cb(null, {}) -- cgit v1.2.3