git ssb

7+

dinoworm 🐛 / patchcore



Commit 06f5ffeda817c287c27c5efa159dd4e31b28b3f9

split out backlink reply mapping into its own file (so it can be used on its own)

Matt McKegg committed on 11/6/2017, 12:21:10 PM
Parent: 976c30737c785b36ead8a46a000292626e4e32c9

Files changed

feed/pull/rollup.jschanged
feed/pull/with-replies.jsadded
feed/pull/rollup.jsView
@@ -3,19 +3,17 @@
33 // accept prioritized list (render these first)
44
55 var pull = require('pull-stream')
66 var nest = require('depnest')
7-var extend = require('xtend')
87 var HLRU = require('hashlru')
9-var resolve = require('mutant/resolve')
10-var onceTrue = require('mutant/once-true')
118
129 exports.needs = nest({
1310 'backlinks.obs.for': 'first',
1411 'sbot.async.get': 'first',
1512 'message.sync.isBlocked': 'first',
1613 'message.sync.root': 'first',
17- 'message.sync.unbox': 'first'
14 + 'message.sync.unbox': 'first',
15 + 'feed.pull.withReplies': 'first'
1816 })
1917
2018 exports.gives = nest('feed.pull.rollup', true)
2119
@@ -87,17 +85,8 @@
8785 pull.filter(rootFilter || (() => true)),
8886 pull.filter(msg => !api.message.sync.isBlocked(msg)),
8987
9088 // ADD REPLIES
91- pull.asyncMap((rootMessage, cb) => {
92- // use global backlinks cache
93- var backlinks = api.backlinks.obs.for(rootMessage.key)
94- onceTrue(backlinks.sync, () => {
95- var replies = resolve(backlinks).filter(msg => {
96- return api.message.sync.root(msg) === rootMessage.key && !api.message.sync.isBlocked(msg)
97- })
98- cb(null, extend(rootMessage, { replies }))
99- })
100- })
89 + api.feed.pull.withReplies()
10190 )
10291 })
10392 }
feed/pull/with-replies.jsView
@@ -1,0 +1,28 @@
1 +var pull = require('pull-stream')
2 +var nest = require('depnest')
3 +var extend = require('xtend')
4 +var resolve = require('mutant/resolve')
5 +var onceTrue = require('mutant/once-true')
6 +
7 +exports.needs = nest({
8 + 'backlinks.obs.for': 'first',
9 + 'message.sync.isBlocked': 'first',
10 + 'message.sync.root': 'first'
11 +})
12 +
13 +exports.gives = nest('feed.pull.withReplies', true)
14 +
15 +exports.create = function (api) {
16 + return nest('feed.pull.withReplies', function () {
17 + return pull.asyncMap((rootMessage, cb) => {
18 + // use global backlinks cache
19 + var backlinks = api.backlinks.obs.for(rootMessage.key)
20 + onceTrue(backlinks.sync, () => {
21 + var replies = resolve(backlinks).filter(msg => {
22 + return api.message.sync.root(msg) === rootMessage.key && !api.message.sync.isBlocked(msg)
23 + })
24 + cb(null, extend(rootMessage, { replies }))
25 + })
26 + })
27 + })
28 +}

Built with git-ssb-web