Optimize game.getDB.

(cherry picked from commit 9f72aebbbd86dff2fe99f683dedb592e1c78b810)
This commit is contained in:
Tipx-L 2023-08-24 08:22:42 -07:00
parent c16a92a24f
commit 97db71b24b
1 changed files with 14 additions and 16 deletions

View File

@ -38169,31 +38169,29 @@
return;
}
lib.status.reload++;
var store=lib.db.transaction([type],'readwrite').objectStore(type);
const store=lib.db.transaction([type],'readwrite').objectStore(type);
if(id){
store.get(id).onsuccess=function(e){
store.get(id).onsuccess=e=>{
_status.dburgent=true;
callback(e.target.result);
delete _status.dburgent;
game.reload2();
};
return;
}
else{
var obj={};
store.openCursor().onsuccess=function(e){
var cursor=e.target.result;
const obj={};
store.openCursor().onsuccess=e=>{
const cursor=e.target.result;
if(cursor){
obj[cursor.key]=cursor.value;
cursor.continue();
return;
}
else{
_status.dburgent=true;
callback(obj);
delete _status.dburgent;
game.reload2();
}
}
}
},
deleteDB:function(type,id,callback){
if(!lib.db){