From 97db71b24b6baf86b84913ef38d85cfb8b70227c Mon Sep 17 00:00:00 2001 From: Tipx-L <138244655+Tipx-L@users.noreply.github.com> Date: Thu, 24 Aug 2023 08:22:42 -0700 Subject: [PATCH] Optimize game.getDB. (cherry picked from commit 9f72aebbbd86dff2fe99f683dedb592e1c78b810) --- game/game.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/game/game.js b/game/game.js index 0a5abf24e..9cb291ff9 100644 --- a/game/game.js +++ b/game/game.js @@ -38169,30 +38169,28 @@ 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; - if(cursor){ - obj[cursor.key]=cursor.value; - cursor.continue(); - } - else{ - _status.dburgent=true; - callback(obj); - delete _status.dburgent; - game.reload2(); - } + const obj={}; + store.openCursor().onsuccess=e=>{ + const cursor=e.target.result; + if(cursor){ + obj[cursor.key]=cursor.value; + cursor.continue(); + return; } + _status.dburgent=true; + callback(obj); + delete _status.dburgent; + game.reload2(); } }, deleteDB:function(type,id,callback){