Commit 51e9718cb367cc06af5a19f5ebafb0887420e957
about: callback early instead of aborting
aborting the stream doesn't seem to work when running as a sbot pluginCharles Lehner committed on 4/21/2016, 8:28:40 PM
Parent: e2ff84468233c659a81da3317c19bb5e5e0bd932
Files changed
about.js | changed |
about.js | ||
---|---|---|
@@ -62,21 +62,31 @@ | ||
62 | 62 | pull.filter(function (msg) { |
63 | 63 | return msg && msg.value.content |
64 | 64 | }), |
65 | 65 | pull.drain(function (msg) { |
66 | - if (info.name && info.image) return false | |
66 | + if (info.name && info.image) | |
67 | + return gotIt() | |
67 | 68 | var c = msg.value.content |
68 | 69 | if (!info.name && c.name) |
69 | 70 | info.name = c.name |
70 | 71 | if (!info.image && c.image) |
71 | 72 | info.image = c.image.link |
72 | - }, function (err) { | |
73 | - if (err && err !== true) return cb(err) | |
74 | - if (!info.name) info.name = truncate(target, 20) | |
75 | - cb(null, info) | |
76 | - }) | |
73 | + }, gotIt) | |
77 | 74 | ) |
78 | 75 | |
76 | + function gotIt(err) { | |
77 | + if (!cb) { | |
78 | + if (err && err !== true) | |
79 | + console.error(err) | |
80 | + return | |
81 | + } | |
82 | + var _cb = cb | |
83 | + cb = null | |
84 | + if (err && err !== true) return _cb(err) | |
85 | + if (!info.name) info.name = truncate(target, 20) | |
86 | + _cb(null, info) | |
87 | + } | |
88 | + | |
79 | 89 | // Keep updated as changes are made |
80 | 90 | pull( |
81 | 91 | sbot.links({ |
82 | 92 | dest: target, |
Built with git-ssb-web