fix @ThinkingJoules 's import 'cannot link undefined' error

This commit is contained in:
Mark Nadal 2018-12-19 04:02:38 -08:00
parent 996db1a42e
commit 3d796b4014
4 changed files with 11 additions and 7 deletions

View File

@ -16,7 +16,7 @@
</head> </head>
<body> <body>
<div id="map"></div> <div id="map"></div>
<a id="share" class="hide"><div class="stick button">Share</div></a> <a id="share" class="hide"><div class="stick button">Request Ride</div></a>
<div id="link" class="hide"> <div id="link" class="hide">
<p>Copy and Paste this URL to your friends to share your location:</p> <p>Copy and Paste this URL to your friends to share your location:</p>
<center> <center>

13
gun.js
View File

@ -400,7 +400,7 @@
return n; return n;
} }
State.to = function(from, k, to){ State.to = function(from, k, to){
var val = from[k]; // BUGGY! var val = (from||{})[k];
if(obj_is(val)){ if(obj_is(val)){
val = obj_copy(val); val = obj_copy(val);
} }
@ -1287,13 +1287,16 @@
return at; return at;
} }
function soul(gun, cb, opt, as){ function soul(gun, cb, opt, as){
var cat = gun._, tmp; var cat = gun._, acks = 0, tmp;
if(tmp = cat.soul){ return cb(tmp, as, cat), gun } if(tmp = cat.soul){ return cb(tmp, as, cat), gun }
if(tmp = cat.link){ return cb(tmp, as, cat), gun } if(tmp = cat.link){ return cb(tmp, as, cat), gun }
gun.get(function(msg, ev){ // TODO: Bug! Needs once semantics? 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;
}
ev.rid(msg); ev.rid(msg);
var at = ((at = msg.$) && at._) || {}; var at = ((at = msg.$) && at._) || {};
tmp = at.link || at.soul || rel.is(msg.put) || node_soul(msg.put); tmp = at.link || at.soul || rel.is(msg.put) || node_soul(msg.put) || at.dub;
cb(tmp, as, msg, ev); cb(tmp, as, msg, ev);
}, {out: {get: {'.':true}}}); }, {out: {get: {'.':true}}});
return gun; return gun;
@ -1344,7 +1347,7 @@
//obj.del(map, at); // TODO: Warning: This unsubscribes ALL of this chain's listeners from this link, not just the one callback event. //obj.del(map, at); // TODO: Warning: This unsubscribes ALL of this chain's listeners from this link, not just the one callback event.
return; return;
} }
var obj = Gun.obj, obj_has = obj.has, obj_to = Gun.obj.to; var obj = Gun.obj, obj_map = obj.map, obj_has = obj.has, obj_to = Gun.obj.to;
var num_is = Gun.num.is; var num_is = Gun.num.is;
var rel = Gun.val.link, node_soul = Gun.node.soul, node_ = Gun.node._; var rel = Gun.val.link, node_soul = Gun.node.soul, node_ = Gun.node._;
var empty = {}, u; var empty = {}, u;

View File

@ -1,6 +1,6 @@
{ {
"name": "gun", "name": "gun",
"version": "0.9.999993", "version": "0.9.999994",
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.", "description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
"main": "index.js", "main": "index.js",
"browser": "gun.min.js", "browser": "gun.min.js",

View File

@ -3705,6 +3705,7 @@ describe('Gun', function(){
}); });
it('Multiple subscribes should trigger', function(done){ it('Multiple subscribes should trigger', function(done){
// thanks to @ivkan for reporting and providing test.
var gun = Gun(); var gun = Gun();
var check = {}; var check = {};
gun.get('m/s/key').put({property: 'value'}); gun.get('m/s/key').put({property: 'value'});