git ssb

16+

Dominic / patchbay



Commit 6a04c1500ae5d062c3a688cf9677d5229a8ca9b1

Handle messages with >1 branch

Charles Lehner committed on 7/11/2016, 6:38:22 AM
Parent: e255333d2b8e29f0eb913728c567b6d707c424bd

Files changed

modules/notifications.jschanged
modules/notifications.jsView
@@ -3,8 +3,9 @@
33 var pull = require('pull-stream')
44 var Scroller = require('pull-scroll')
55 var paramap = require('pull-paramap')
66 var plugs = require('../plugs')
7+var cont = require('cont')
78
89 var message_render = plugs.first(exports.message_render = [])
910 var sbot_log = plugs.first(exports.sbot_log = [])
1011 var sbot_whoami = plugs.first(exports.sbot_whoami = [])
@@ -48,17 +49,16 @@
4849 return cb(null, msg)
4950
5051 switch (c.type) {
5152 case 'post':
52- if (c.branch)
53- return isOurMsg(c.branch, function (err, isOurs) {
53+ if (c.branch || c.root)
54+ cont.para([].concat(c.branch, c.root).map(function (id) {
55+ return function (cb) { isOurMsg(id, cb) }
56+ }))
57+ (function (err, results) {
5458 if (err) cb(err)
55- else if (isOurs) cb(null, msg)
56- else if (c.root) isOurMsg(c.root, function (err, isOurs) {
57- if (err) cb(err)
58- else if (isOurs) cb(null, msg)
59- else cb()
60- })
59+ else if (results.some(Boolean)) cb(null, msg)
60+ else cb()
6161 })
6262 else return cb()
6363
6464 case 'contact':

Built with git-ssb-web