Files: d6861e3a6c97728f151fbc42d87fe7b565358976 / bookmark / obs / bookmark.js
864 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.groupedValues': 'first', |
9 | 'bookmark.obs.struct': 'first' |
10 | }) |
11 | |
12 | exports.gives = nest('bookmark.obs.bookmark') |
13 | |
14 | exports.create = function(api) { |
15 | return nest('bookmark.obs.bookmark', function(bookmarkId) { |
16 | if (!ref.isLink(bookmarkId)) throw new Error('an id must be specified') |
17 | |
18 | const { latestValue, groupedValues } = api.about.obs |
19 | |
20 | const bookmark = api.bookmark.obs.struct({ |
21 | title: latestValue(bookmarkId, 'title'), |
22 | description: latestValue(bookmarkId, 'description'), |
23 | messageId: latestValue(bookmarkId, 'messageId'), |
24 | tags: computed([groupedValues(bookmarkId, 'tags')], Object.keys) |
25 | }) |
26 | |
27 | return bookmark |
28 | }) |
29 | } |
30 |
Built with git-ssb-web