git ssb

0+

Josiah / patchbay-tags



Tree: d6861e3a6c97728f151fbc42d87fe7b565358976

Files: d6861e3a6c97728f151fbc42d87fe7b565358976 / bookmark / obs / bookmark.js

864 bytesRaw
1const nest = require('depnest')
2const pull = require('pull-stream')
3const ref = require('ssb-ref')
4const { computed } = require('mutant')
5
6exports.needs = nest({
7 'about.obs.latestValue': 'first',
8 'about.obs.groupedValues': 'first',
9 'bookmark.obs.struct': 'first'
10})
11
12exports.gives = nest('bookmark.obs.bookmark')
13
14exports.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