Files: 653e7d95783fcb22649a1ce70a47fc0deb571e3f / bookmark / obs / bookmark.js
816 bytesRaw
1 | const nest = require('depnest') |
2 | const pull = require('pull-stream') |
3 | const ref = require('ssb-ref') |
4 | const { computed } = require('mutant') |
5 | |
6 | exports.needs = nest({ |
7 | 'about.obs.latestValue': 'first', |
8 | 'about.obs.valueFrom': 'first', |
9 | 'about.obs.groupedValues': 'first', |
10 | 'bookmark.obs.struct': 'first' |
11 | }) |
12 | |
13 | exports.gives = nest('bookmark.obs.bookmark') |
14 | |
15 | exports.create = function(api) { |
16 | return nest('bookmark.obs.bookmark', function(messageId, id) { |
17 | if (!ref.isLink(messageId)) throw new Error('an id must be specified') |
18 | |
19 | const { latestValue, valueFrom, groupedValues } = api.about.obs |
20 | |
21 | const bookmark = api.bookmark.obs.struct({ |
22 | notes: latestValue(messageId, 'notes'), |
23 | tags: valueFrom(messageId, 'tags', id), |
24 | recps: latestValue(messageId, 'recps') |
25 | }) |
26 | |
27 | return bookmark |
28 | }) |
29 | } |
30 |
Built with git-ssb-web