git ssb

3+

arj / patchbook



Tree: f9490b57823c88d2d4e1cdc8495b8ab60d63862f

Files: f9490b57823c88d2d4e1cdc8495b8ab60d63862f / book / pull / getAll.js

1018 bytesRaw
1const pull = require('pull-stream')
2const many = require('pull-many')
3const sort = require('pull-sort')
4const timestamp = require('monotonic-timestamp')
5const nest = require('depnest')
6
7exports.gives = nest({
8 'book.pull.getAll': true
9})
10
11exports.needs = nest({
12 'sbot.pull.messagesByType': 'first'
13})
14
15exports.create = function (api) {
16 return nest({ 'book.pull.getAll': getAll })
17
18 function getLive() {
19 return api.sbot.pull.messagesByType({ type: 'bookclub', fillCache: true,
20 keys: true, reverse: false,
21 live: true, gt: timestamp() })
22 }
23
24 function getCurrent() {
25 return api.sbot.pull.messagesByType({ type: 'bookclub', fillCache: true,
26 keys: true, reverse: false })
27 }
28
29 function getAll() {
30 return pull(
31 many([
32 pull(
33 getCurrent(),
34 sort((a, b) => a.value.timestamp - b.value.timestamp)
35 ),
36 getLive()
37 ])
38 )
39 }
40}
41

Built with git-ssb-web