aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-11 20:25:59 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-11 20:26:52 -1000
commit24417ffb7f896971664053a13101154e40d6adce (patch)
tree11c11573e50c0ba17cd5a92a57e3b485b08f966e /lib
parent9ebb886a032f3a3767c24dce9a343311ea8c4481 (diff)
downloadpatchfoo-24417ffb7f896971664053a13101154e40d6adce.tar.gz
patchfoo-24417ffb7f896971664053a13101154e40d6adce.zip
Optimize streaming my channels
Diffstat (limited to 'lib')
-rw-r--r--lib/app.js18
1 files changed, 18 insertions, 0 deletions
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(),