Commit 5f748b6b2f66486956478df91eba0a3689e4ade9
naive: when ssb is remote, use getLatest (contains races)
Dominic Tarr committed on 6/19/2016, 2:38:08 AMParent: e46f01697514f750036ba3c5badb545dbbd8bc5a
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -39,12 +39,22 @@ | ||
39 | 39 | |
40 | 40 | var err = util.isInvalidContent(message) |
41 | 41 | if(err) return cb(err) |
42 | 42 | |
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 | + } | |
46 | 48 | |
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 | + | |
47 | 57 | return this |
48 | 58 | }) |
49 | 59 | |
50 | 60 | return { |
@@ -55,4 +65,5 @@ | ||
55 | 65 | } |
56 | 66 | } |
57 | 67 | |
58 | 68 | |
69 | + |
Built with git-ssb-web