git ssb

3+

arj / patchbook



Commit 8f2aca38aa67fc3bb380305c95663dfaeb670693

Pull in all comments

Anders Rune Jensen committed on 1/2/2018, 9:19:09 PM
Parent: 5bd022593cbd8e9908ea16f9dbdbb634e8dcd56b

Files changed

book/async/get.jschanged
book/obs/book.jschanged
book/async/get.jsView
@@ -32,9 +32,10 @@
3232 key,
3333 common: msg.content,
3434 subjective: {
3535 [api.keys.sync.id()]: {
36- key: '', rating: '', ratingType: '', review: '', shelve: '', genre: '', comments: []
36 + key: '', allKeys: [], rating: '', ratingType: '', review: '',
37 + shelve: '', genre: '', comments: []
3738 }
3839 }
3940 }
4041
@@ -50,33 +51,40 @@
5051 pull.values(Object.values(book.subjective)),
5152 pull.drain(subj => {
5253 if (subj.key) {
5354 pull(
54- api.sbot.pull.links({ dest: subj.key, live: true }),
55- pull.filter(data => data.key),
56- pull.asyncMap((data, cb) => {
57- api.sbot.async.get(data.key, (err, msg) => {
58- msg.key = data.key
59- cb(err, msg)
60- })
61- }),
62- //sort((a, b) => a.timestamp - b.timestamp),
63- pull.drain(msg => {
64- if (msg.content.type !== "post") return
55 + pull.values(Object.values(subj.allKeys)),
56 + pull.drain(key => {
57 + pull(
58 + api.sbot.pull.links({ dest: key, live: key == subj.key }),
59 + pull.filter(data => data.key),
60 + pull.asyncMap((data, cb) => {
61 + api.sbot.async.get(data.key, (err, msg) => {
62 + msg.key = data.key
63 + cb(err, msg)
64 + })
65 + }),
66 + //sort((a, b) => a.timestamp - b.timestamp),
67 + pull.drain(msg => {
68 + if (msg.content.type !== "post") return
6569
66- // FIXME: links is buggy and returns the same message twice
67- if (!subj.comments.some(c => c.content.text == msg.content.text)) {
68- subj.comments.push(msg)
69- cb(book)
70- }
70 + // FIXME: links is buggy and returns the same message twice
71 + if (!subj.comments.some(c => c.content.text == msg.content.text)) {
72 + subj.comments.push(msg)
73 + cb(book)
74 + }
75 + })
76 + )
7177 })
7278 )
7379 }
7480 }, () => cb(book))
7581 )
7682 }
7783
7884 function applyAmends(book, cb) {
85 + let allAuthorKeys = {}
86 +
7987 pull(
8088 api.sbot.pull.links({ dest: book.key }), // FIXME: can't do live
8189 // together with
8290 // sorting and links
@@ -93,11 +101,18 @@
93101 if (msg.content.type !== "about") return
94102
95103 const { rating, ratingType, shelve, genre, review } = msg.content
96104
105 + if (!allAuthorKeys[msg.author])
106 + allAuthorKeys[msg.author] = []
107 +
108 + let allKeys = allAuthorKeys[msg.author]
109 + allKeys.push(msg.key)
110 +
97111 if (rating || ratingType || shelve || genre || review) {
98112 book.subjective[msg.author] = {
99113 key: msg.key,
114 + allKeys,
100115 rating,
101116 ratingType,
102117 shelve,
103118 genre,
book/obs/book.jsView
@@ -76,8 +76,9 @@
7676
7777 // ui convenience
7878 delete msg.comments
7979 delete msg.key
80 + delete msg.allKeys
8081
8182 api.sbot.async.publish(msg, cb)
8283 }
8384

Built with git-ssb-web