Files: f9490b57823c88d2d4e1cdc8495b8ab60d63862f / book / pull / getAll.js
1018 bytesRaw
1 | const pull = require('pull-stream') |
2 | const many = require('pull-many') |
3 | const sort = require('pull-sort') |
4 | const timestamp = require('monotonic-timestamp') |
5 | const nest = require('depnest') |
6 | |
7 | exports.gives = nest({ |
8 | 'book.pull.getAll': true |
9 | }) |
10 | |
11 | exports.needs = nest({ |
12 | 'sbot.pull.messagesByType': 'first' |
13 | }) |
14 | |
15 | exports.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