diff --git a/examples/basic/user.html b/examples/basic/user.html
index 9ae9b009..873d517c 100644
--- a/examples/basic/user.html
+++ b/examples/basic/user.html
@@ -5,7 +5,7 @@
-
+
diff --git a/gun.js b/gun.js
index 52e8d3ac..0e8e5508 100644
--- a/gun.js
+++ b/gun.js
@@ -1160,7 +1160,10 @@
if(!(at.has || at.soul)){ return }
var tmp = at.map, root = at.root;
at.map = null;
- if(at.has){ at.link = null }
+ if(at.has){
+ if(at.dub && at.root.stop){ at.dub = null }
+ at.link = null;
+ }
//if(!root.now || !root.now[at.id]){
if(!at.pass){
if((!msg['@']) && null === tmp){ return }
@@ -1286,8 +1289,7 @@
}
function soul(gun, cb, opt, as){
var cat = gun._, acks = 0, tmp;
- if(tmp = cat.soul){ return cb(tmp, as, cat), gun }
- if(tmp = cat.link){ return cb(tmp, as, cat), gun }
+ if(tmp = cat.soul || cat.link || cat.dub){ return cb(tmp, as, cat), gun }
gun.get(function(msg, ev){
if(u === msg.put && (tmp = (obj_map(cat.root.opt.peers, function(v,k,t){t(k)})||[]).length) && ++acks < tmp){
return;
@@ -1397,6 +1399,7 @@
}, true);
return gun;
}
+ if(at.has && (tmp = Gun.val.link.is(data))){ at.dub = tmp }
as.ref = as.ref || (root._ === (tmp = at.back))? gun : tmp.$;
if(as.ref._.soul && Gun.val.is(as.data) && at.get){
as.data = obj_put({}, at.get, as.data);
@@ -1551,7 +1554,7 @@
if(node_ == at.get){
as.soul = (at.put||empty)['#'] || at.dub;
}
- as.soul = as.soul || at.soul || at.soul || (opt.uuid || as.via.back('opt.uuid') || Gun.text.random)();
+ as.soul = as.soul || at.soul || at.link || (opt.uuid || as.via.back('opt.uuid') || Gun.text.random)();
}
if(!as.soul){ // polyfill async uuid for SEA
as.via.back('opt.uuid')(function(err, soul){ // TODO: improve perf without anonymous callback
diff --git a/package.json b/package.json
index f3c57aa0..2cf8e82d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gun",
- "version": "0.9.999999",
+ "version": "0.9.9999991",
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
"main": "index.js",
"browser": "gun.min.js",
diff --git a/test/common.js b/test/common.js
index 4b754270..5254bbcd 100644
--- a/test/common.js
+++ b/test/common.js
@@ -1265,13 +1265,14 @@ describe('Gun', function(){
describe('API', function(){
var gopt = {wire:{put:function(n,cb){cb()},get:function(k,cb){cb()}}};
if(Gun.window && location.search){
- console.log("LOCALHOST PEER MUST BE ON!");
+ /*console.log("LOCALHOST PEER MUST BE ON!");
+ var peer = {url: 'http://localhost:8765/gun'};
Gun.on('opt', function(root){
if(root.opt.test_no_peer){ return this.to.next(root) }
root.opt.peers = root.opt.peers || {};
- root.opt.peers['http://localhost:8765/gun'] = {url: 'http://localhost:8765/gun'};
+ root.opt.peers['http://localhost:8765/gun'] = peer;
this.to.next(root);
- });
+ });*/
}
var gun = Gun();
@@ -3755,6 +3756,19 @@ describe('Gun', function(){
});
//});
});
+
+ it('Set a ref should be found', function(done){
+ var gun = Gun();
+ var msg = {what: 'hello world'};
+ //var ref = user.get('who').get('all').set(msg);
+ //user.get('who').get('said').set(ref);
+ var ref = gun.get('who').get('all').set(msg);
+ gun.get('who').get('said').set(ref);
+ gun.get('who').get('said').map().once(function(data){
+ expect(data.what).to.be.ok();
+ done();
+ })
+ });
return;
it('Nested listener should be called', function(done){
diff --git a/test/sea/sea.js b/test/sea/sea.js
index 4a6836f7..52dbbcb2 100644
--- a/test/sea/sea.js
+++ b/test/sea/sea.js
@@ -317,6 +317,45 @@ describe('SEA', function(){
done();
});
})
+
+ it('set user ref should be found', function(done){
+ var gun = Gun();
+ var user = gun.user();
+ var msg = {what: 'hello world'};
+ user.create('zach', 'password');
+ gun.on('auth', function(){
+ var ref = user.get('who').get('all').set(msg);
+ user.get('who').get('said').set(ref);
+ user.get('who').get('said').map().once(function(data){
+ expect(data.what).to.be.ok();
+ done();
+ })
+ })
+ });
+
+ it('set user ref null override', function(done){
+ var gun = Gun();
+ var user = gun.user();
+ var msg = {what: 'hello world'};
+ user.create('xavier', 'password');
+ gun.on('auth', function(){
+ var ref = user.get('who').get('all').set(msg);
+ var tmp = ref._.dub || ref._.link;
+ setTimeout(function(){
+ user.get('who').put(1);
+ setTimeout(function(){
+ user.get('who').get('all').get(tmp).put({boom: 'ah'});
+ setTimeout(function(){
+ user.get('who').get('all').map().once(function(data){
+ expect(data).to.be.ok();
+ expect(data.what).to.not.be.ok();
+ done();
+ });
+ },9);
+ },9);
+ },9);
+ });
+ });
});
})