localStorage:error retry option

This commit is contained in:
Mark Nadal 2018-05-24 15:36:30 -07:00
parent 80840725e4
commit 24eb1d31c0
3 changed files with 7 additions and 5 deletions

5
gun.js
View File

@ -1869,17 +1869,18 @@
disk[soul] = Gun.state.to(node, key, disk[soul]);
}
var flush = function(){
var flush = function(data){
var err;
count = 0;
clearTimeout(to);
to = false;
var ack = acks;
acks = {};
if(data){ disk = data }
try{store.setItem(opt.file, JSON.stringify(disk));
}catch(e){
Gun.log(err = e || "localStorage failure");
root.on('localStorage:error', {err: err, file: opt.file});
root.on('localStorage:error', {err: err, file: opt.file, flush: disk, retry: flush});
}
if(!err && !Gun.obj.empty(opt.peers)){ return } // only ack if there are no peers.
Gun.obj.map(ack, function(yes, id){

2
gun.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -120,17 +120,18 @@ Gun.on('create', function(root){
disk[soul] = Gun.state.to(node, key, disk[soul]);
}
var flush = function(){
var flush = function(data){
var err;
count = 0;
clearTimeout(to);
to = false;
var ack = acks;
acks = {};
if(data){ disk = data }
try{store.setItem(opt.file, JSON.stringify(disk));
}catch(e){
Gun.log(err = e || "localStorage failure");
root.on('localStorage:error', {err: err, file: opt.file});
root.on('localStorage:error', {err: err, file: opt.file, flush: disk, retry: flush});
}
if(!err && !Gun.obj.empty(opt.peers)){ return } // only ack if there are no peers.
Gun.obj.map(ack, function(yes, id){