Commit 24417ffb7f896971664053a13101154e40d6adce
Optimize streaming my channels
cel committed on 5/12/2017, 6:26:52 AMParent: 9ebb886a032f3a3767c24dce9a343311ea8c4481
Files changed
lib/app.js | changed |
lib/app.js | ||
---|---|---|
@@ -282,8 +282,26 @@ | ||
282 | 282 … | ) |
283 | 283 … | } |
284 | 284 … | |
285 | 285 … | App.prototype.streamMyChannels = function (id, opts) { |
286 … | + // use ssb-query plugin if it is available, since it has an index for | |
287 … | + // author + type | |
288 … | + if (this.sbot.query) return pull( | |
289 … | + this.sbot.query.read({ | |
290 … | + reverse: true, | |
291 … | + query: [ | |
292 … | + {$filter: { | |
293 … | + value: { | |
294 … | + author: id, | |
295 … | + content: {type: 'channel', subscribed: true} | |
296 … | + } | |
297 … | + }}, | |
298 … | + {$map: ['value', 'content', 'channel']} | |
299 … | + ] | |
300 … | + }), | |
301 … | + pull.unique() | |
302 … | + ) | |
303 … | + | |
286 | 304 … | return pull( |
287 | 305 … | this.sbot.createUserStream({id: id, reverse: true}), |
288 | 306 … | this.unboxMessages(), |
289 | 307 … | pull.filter(function (msg) { |
Built with git-ssb-web