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 AMParent: 460327c4ff4a7fbb7266be536dba9f071b8edca8
Files changed
modules/thread.js | changed |
modules/thread.js | ||
---|---|---|
@@ -29,20 +29,34 @@ | ||
29 | 29 | |
30 | 30 | var sbot_get = plugs.first(exports.sbot_get = []) |
31 | 31 | var sbot_links = plugs.first(exports.sbot_links = []) |
32 | 32 | |
33 | -function getThread (root, sbot, cb) { | |
33 | +function getThread (root, cb) { | |
34 | 34 | //in this case, it's inconvienent that panel only takes |
35 | 35 | //a stream. maybe it would be better to accept an array? |
36 | 36 | |
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) | |
41 | 47 | }) |
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)) | |
45 | 59 | } |
46 | 60 | |
47 | 61 | exports.screen_view = function (id, sbot) { |
48 | 62 | if(ref.isMsg(id)) { |
@@ -69,9 +83,9 @@ | ||
69 | 83 | ) |
70 | 84 | |
71 | 85 | |
72 | 86 | function loadThread () { |
73 | - getThread(id, sbot, function (err, thread) { | |
87 | + getThread(id, function (err, thread) { | |
74 | 88 | //would probably be better keep an id for each message element |
75 | 89 | //(i.e. message key) and then update it if necessary. |
76 | 90 | //also, it may have moved (say, if you received a missing message) |
77 | 91 | content.innerHTML = '' |
@@ -85,8 +99,9 @@ | ||
85 | 99 | }) |
86 | 100 | |
87 | 101 | var branches = sort.heads(thread) |
88 | 102 | meta.branch = branches.length > 1 ? branches : branches[0] |
103 | + meta.root = thread[0].key | |
89 | 104 | |
90 | 105 | var recps = thread[0].value.content.recps |
91 | 106 | if(recps && thread[0].value.private) |
92 | 107 | meta.recps = recps |
@@ -98,4 +113,7 @@ | ||
98 | 113 | } |
99 | 114 | } |
100 | 115 | |
101 | 116 | |
117 | + | |
118 | + | |
119 | + |
Built with git-ssb-web