localStorage:error event

This commit is contained in:
Mark Nadal 2018-05-24 15:20:35 -07:00
parent 6fd70c3e6a
commit 80840725e4
7 changed files with 17 additions and 7 deletions

View File

@ -126,6 +126,7 @@
}
chat.map().val(function(msg, id){
if(!msg){ return }
var ul = $('ul');
var last = sort(msg.when, ul.children('li').last());

View File

@ -95,7 +95,7 @@
</form>
<div>
<ul name="said">
<li name="#" class="sit sort shade rim"><div name="what" class="rim sit"></div></li>
<li name="#" class="sit sort shade rim"><div name="what" class="rim"></div></li>
</ul>
</div>
</div>

5
gun.js
View File

@ -1877,7 +1877,10 @@
var ack = acks;
acks = {};
try{store.setItem(opt.file, JSON.stringify(disk));
}catch(e){ Gun.log(err = e || "localStorage failure") }
}catch(e){
Gun.log(err = e || "localStorage failure");
root.on('localStorage:error', {err: err, file: opt.file});
}
if(!err && !Gun.obj.empty(opt.peers)){ return } // only ack if there are no peers.
Gun.obj.map(ack, function(yes, id){
root.on('in', {

2
gun.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -128,7 +128,10 @@ Gun.on('create', function(root){
var ack = acks;
acks = {};
try{store.setItem(opt.file, JSON.stringify(disk));
}catch(e){ Gun.log(err = e || "localStorage failure") }
}catch(e){
Gun.log(err = e || "localStorage failure");
root.on('localStorage:error', {err: err, file: opt.file});
}
if(!err && !Gun.obj.empty(opt.peers)){ return } // only ack if there are no peers.
Gun.obj.map(ack, function(yes, id){
root.on('in', {

View File

@ -1,10 +1,10 @@
var Gun = require('./root');
Gun.chain.get = function(key, cb, as){
var gun;
var gun, tmp;
if(typeof key === 'string'){
var back = this, cat = back._;
var next = cat.next || empty, tmp;
var next = cat.next || empty;
if(!(gun = next[key])){
gun = cache(key, back);
}
@ -25,6 +25,9 @@ Gun.chain.get = function(key, cb, as){
} else
if(num_is(key)){
return this.get(''+key, cb, as);
} else
if(tmp = rel.is(key)){
return this.get(tmp, cb, as);
} else {
(as = this.chain())._.err = {err: Gun.log('Invalid get request!', key)}; // CLEAN UP
if(cb){ cb.call(as, as._.err) }

View File

@ -68,7 +68,7 @@ describe("Make sure the Radix Storage Engine (RSE) works.", function(){
});
var Gun = require('gun');
require('gun/lib/store');
var gun = Gun({web: server, localStorage: false, thrash: 6000});
var gun = Gun({web: server, localStorage: false, until: 6000});
server.listen(port, function(){
test.done();
});