git ssb

16+

Dominic / patchbay



Commit 34d99e9e2271da97998a436bbf03e9a3a5b80d16

ensure that a reply to a reply is treated as a reply to that thread.

Dominic Tarr committed on 6/11/2016, 12:35:11 AM
Parent: 460327c4ff4a7fbb7266be536dba9f071b8edca8

Files changed

modules/thread.jschanged
modules/thread.jsView
@@ -29,20 +29,34 @@
2929
3030 var sbot_get = plugs.first(exports.sbot_get = [])
3131 var sbot_links = plugs.first(exports.sbot_links = [])
3232
33-function getThread (root, sbot, cb) {
33+function getThread (root, cb) {
3434 //in this case, it's inconvienent that panel only takes
3535 //a stream. maybe it would be better to accept an array?
3636
37- return pull(Cat([
38- once(function (cb) {
39- sbot_get(root, function (err, value) {
40- cb(err, {key: root, value: value})
37+ sbot_get(root, function (err, value) {
38+ var msg = {key: root, value: value}
39+ if(value.content.root) return getThread(value.content.root, cb)
40+
41+ pull(
42+ sbot_links({rel: 'root', dest: root, values: true, keys: true}),
43+ pull.collect(function (err, ary) {
44+ if(err) return cb(err)
45+ ary.unshift(msg)
46+ cb(null, ary)
4147 })
42- }),
43- sbot_links({rel: 'root', dest: root, values: true, keys: true})
44- ]), pull.collect(cb))
48+ )
49+ })
50+
51+// return pull(Cat([
52+// once(function (cb) {
53+// sbot_get(root, function (err, value) {
54+// cb(err, {key: root, value: value})
55+// })
56+// }),
57+// sbot_links({rel: 'root', dest: root, values: true, keys: true})
58+// ]), pull.collect(cb))
4559 }
4660
4761 exports.screen_view = function (id, sbot) {
4862 if(ref.isMsg(id)) {
@@ -69,9 +83,9 @@
6983 )
7084
7185
7286 function loadThread () {
73- getThread(id, sbot, function (err, thread) {
87+ getThread(id, function (err, thread) {
7488 //would probably be better keep an id for each message element
7589 //(i.e. message key) and then update it if necessary.
7690 //also, it may have moved (say, if you received a missing message)
7791 content.innerHTML = ''
@@ -85,8 +99,9 @@
8599 })
86100
87101 var branches = sort.heads(thread)
88102 meta.branch = branches.length > 1 ? branches : branches[0]
103+ meta.root = thread[0].key
89104
90105 var recps = thread[0].value.content.recps
91106 if(recps && thread[0].value.private)
92107 meta.recps = recps
@@ -98,4 +113,7 @@
98113 }
99114 }
100115
101116
117+
118+
119+

Built with git-ssb-web