git ssb

7+

dinoworm 🐛 / patchcore



Commit ea367c48e4de385f8dc1b8e39b58fcab4ad8d4b7

feed.pull: add more, accept `lt` value as objects, extract correct seq out

Matt McKegg committed on 6/15/2017, 5:19:05 AM
Parent: 0cae923ff917e2cab616dee0db56d2e4cf5f66c8

Files changed

feed/pull/channel.jschanged
feed/pull/mentions.jschanged
feed/pull/private.jschanged
feed/pull/public.jschanged
feed/pull/profile.jsadded
feed/pull/channel.jsView
@@ -10,19 +10,23 @@
1010 return nest('feed.pull.channel', function (channel) {
1111 if (typeof channel !== 'string') throw new Error('a channel name be specified')
1212
1313 return function (opts) {
14 + // handle last item passed in as lt
15 + var lt = typeof opts.lt === 'object'
16 + ? opts.lt.value.timestamp
17 + : opts.lt
18 +
19 + delete opts.lt
20 +
1421 var filter = {
1522 dest: `#${channel}`,
16- timestamp: opts.lt
17- ? {$lt: opts.lt, $gt: 0}
18- : {$gt: 0}
23 + value: {
24 + timestamp: lt ? {$lt: lt, $gt: 0} : {$gt: 0}
25 + }
1926 }
2027
21- delete opts.lt
22-
2328 return api.sbot.pull.backlinks(extend(opts, {
24- index: 'DTS', // HACK: force index since flumeview-query is choosing the wrong one
2529 query: [
2630 {$filter: filter}
2731 ]
2832 }))
feed/pull/mentions.jsView
@@ -20,8 +20,13 @@
2020 opts = extend(opts)
2121 var take = opts.limit
2222 opts.limit = 5000
2323
24 + // handle last item passed in as lt
25 + opts.lt = typeof opts.lt === 'object'
26 + ? opts.lt.timestamp
27 + : opts.lt
28 +
2429 var stream = pull(
2530 api.sbot.pull.log(opts),
2631 unboxIfNeeded(),
2732 pull.filter((msg) => {
feed/pull/private.jsView
@@ -8,19 +8,23 @@
88 })
99
1010 exports.create = function (api) {
1111 return nest('feed.pull.private', function (opts) {
12 + // handle last item passed in as lt
13 + var lt = typeof opts.lt === 'object'
14 + ? opts.lt.timestamp
15 + : opts.lt
16 + delete opts.lt
17 +
1218 // HACK: needed to select correct index and handle lt
1319 opts.query = [
1420 {$filter: {
15- timestamp: opts.lt
16- ? {$lt: opts.lt, $gt: 0}
21 + timestamp: lt
22 + ? {$lt: lt, $gt: 0}
1723 : {$gt: 0}
1824 }}
1925 ]
2026
21- delete opts.lt
22-
2327 return StreamWhenConnected(api.sbot.obs.connection, (sbot) => {
2428 return sbot.private.read(opts)
2529 })
2630 })
feed/pull/public.jsView
@@ -1,7 +1,13 @@
11 const nest = require('depnest')
22
33 exports.gives = nest('feed.pull.public')
4-exports.needs = nest('sbot.pull.log', 'first')
4 +exports.needs = nest('sbot.pull.feed', 'first')
55 exports.create = function (api) {
6- return nest('feed.pull.public', api.sbot.pull.log)
6 + return nest('feed.pull.public', (opts) => {
7 + // handle last item passed in as lt
8 + opts.lt = typeof opts.lt === 'object'
9 + ? opts.lt.value.timestamp
10 + : opts.lt
11 + return api.sbot.pull.feed(opts)
12 + })
713 }
feed/pull/profile.jsView
@@ -1,0 +1,16 @@
1 +const nest = require('depnest')
2 +const extend = require('xtend')
3 +
4 +exports.gives = nest('feed.pull.profile')
5 +exports.needs = nest('sbot.pull.userFeed', 'first')
6 +exports.create = function (api) {
7 + return nest('feed.pull.profile', (id) => {
8 + // handle last item passed in as lt
9 + return function (opts) {
10 + opts = extend(opts, {
11 + id, lt: typeof opts.lt === 'object' ? opts.lt.value.sequence : opts.lt
12 + })
13 + return api.sbot.pull.userFeed(opts)
14 + }
15 + })
16 +}

Built with git-ssb-web