From 24417ffb7f896971664053a13101154e40d6adce Mon Sep 17 00:00:00 2001 From: cel Date: Thu, 11 May 2017 20:25:59 -1000 Subject: Optimize streaming my channels --- lib/app.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/app.js b/lib/app.js index f475bd2..6990aa5 100644 --- a/lib/app.js +++ b/lib/app.js @@ -283,6 +283,24 @@ App.prototype.streamChannels = function (opts) { } App.prototype.streamMyChannels = function (id, opts) { + // use ssb-query plugin if it is available, since it has an index for + // author + type + if (this.sbot.query) return pull( + this.sbot.query.read({ + reverse: true, + query: [ + {$filter: { + value: { + author: id, + content: {type: 'channel', subscribed: true} + } + }}, + {$map: ['value', 'content', 'channel']} + ] + }), + pull.unique() + ) + return pull( this.sbot.createUserStream({id: id, reverse: true}), this.unboxMessages(), -- cgit v1.2.3