mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
fix localStorage edits
This commit is contained in:
parent
a090ee3a2f
commit
1a4a7ac6f6
@ -8,7 +8,7 @@
|
||||
}
|
||||
, "dependencies": {
|
||||
"express": "~>4.9.0",
|
||||
"gun": "0.0.9-k"
|
||||
"gun": "0.0.9-l"
|
||||
}
|
||||
, "scripts": {
|
||||
"start": "node express.js",
|
||||
|
15
gun.js
15
gun.js
@ -913,28 +913,25 @@
|
||||
opt.url.pathname = '/' + key;
|
||||
}
|
||||
Gun.log("gun load", key);
|
||||
(function(){
|
||||
(function local(key, cb){
|
||||
var node, lkey = key[Gun._.soul]? tab.prefix + tab.prenode + key[Gun._.soul]
|
||||
: tab.prefix + tab.prekey + key
|
||||
if((node = store.get(lkey)) && node[Gun._.soul]){ return tab.load(node, cb) }
|
||||
setTimeout(function(){cb(null, node)},0);
|
||||
}());
|
||||
if((node = store.get(lkey)) && node[Gun._.soul]){ return local(node, cb) }
|
||||
if(node){ setTimeout(function(){cb(null, node)},0) }
|
||||
}(key, cb));
|
||||
Gun.obj.map(gun.__.opt.peers, function(peer, url){
|
||||
request(url, null, function(err, reply){
|
||||
Gun.log('via', url, key, reply.body);
|
||||
if(err || !reply){ return } // handle reconnect?
|
||||
if(reply.body && reply.body.err){
|
||||
cb(reply.body.err);
|
||||
} else
|
||||
if(Gun.is.node(reply.body) || Gun.is.graph(reply.body)){
|
||||
} else {
|
||||
if(!key[Gun._.soul] && Gun.is.soul(reply.body)){
|
||||
var meta = {};
|
||||
meta[Gun._.soul] = Gun.is.soul(reply.body);
|
||||
store.set(tab.prefix + tab.prekey + key, meta)
|
||||
store.set(tab.prefix + tab.prekey + key, meta);
|
||||
}
|
||||
cb(null, reply.body);
|
||||
} else {
|
||||
Gun.log(reply.body);
|
||||
}
|
||||
}, opt);
|
||||
cb.peers = true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
{ "name": "gun"
|
||||
, "version": "0.0.9-k"
|
||||
, "version": "0.0.9-l"
|
||||
, "author": "Mark Nadal"
|
||||
, "description": "Graph engine."
|
||||
, "engines": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user