git ssb

0+

Dominic / ssb-feed



Commit 5f748b6b2f66486956478df91eba0a3689e4ade9

naive: when ssb is remote, use getLatest (contains races)

Dominic Tarr committed on 6/19/2016, 2:38:08 AM
Parent: e46f01697514f750036ba3c5badb545dbbd8bc5a

Files changed

index.jschanged
index.jsView
@@ -39,12 +39,22 @@
3939
4040 var err = util.isInvalidContent(message)
4141 if(err) return cb(err)
4242
43- return ssb.add.queue(keys.id, function (key, value) {
44- return util.create(keys, null, message, value, key)
45- }, cb)
43+ if(ssb.add.queue) {
44+ return ssb.add.queue(keys.id, function (key, value) {
45+ return util.create(keys, null, message, value, key)
46+ }, cb)
47+ }
4648
49+ ssb.getLatest(keys.id, function (err, data) {
50+ var msg = data
51+ ? util.create(keys, null, message, data.value, data.key)
52+ : util.create(keys, null, message, null, null)
53+
54+ ssb.add(msg, cb)
55+ })
56+
4757 return this
4858 })
4959
5060 return {
@@ -55,4 +65,5 @@
5565 }
5666 }
5767
5868
69+

Built with git-ssb-web