Skip to content

Commit

Permalink
Fix: Performance issues when generating some thumbnails
Browse files Browse the repository at this point in the history
  • Loading branch information
ollm committed Dec 8, 2023
1 parent f409dbb commit 1a07d2d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Delete bookmarks from the bookmark list [`3792f7d`](https://github.com/ollm/OpenComic/commit/3792f7db319cf885f398836aefe983e56fe5ef2a)
- Save and show also the current folder progress apart from the main folder [`86f094b`](https://github.com/ollm/OpenComic/commit/86f094b7a216982ae7799950234be233113143e7)
- Instead of the file name it shows the title of EPUB, PDF and Compressed Files with ComicInfo.xml
- Instead of the file name it shows the title of EPUB, PDF and Compressed Files with ComicInfo.xml [`0d3e4ba`](https://github.com/ollm/OpenComic/commit/0d3e4ba489f616d862c4b52e2f2498f1a203d218)

##### 🐛 Bug Fixes

Expand All @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Blank page keep white color in dark theme [`8d1a5b7`](https://github.com/ollm/OpenComic/commit/8d1a5b741855fd0bae6a7efd9579c7ddecbfd3d1)
- Open with OpenComic not working in macOS and some fixes in Windows and Linux [`ea90063`](https://github.com/ollm/OpenComic/commit/ea9006309eee995c92571e0bc4c919d50de8e55b)
- Error opening an epub when OpenComic is closed [`84c838a`](https://github.com/ollm/OpenComic/commit/84c838a17a32b3f50e9b25bf016ea810c91d95e6)
- Performance issues when generating some thumbnails

## [v1.0.0-beta.5](https://github.com/ollm/OpenComic/releases/tag/v1.0.0-beta.5) (24-11-2023)

Expand Down
4 changes: 2 additions & 2 deletions scripts/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function processTheImageQueue()
{
processingTheImageQueue = false;

storage.set('cache', data);
storage.setThrottle('cache', data);
}

}).catch(function(){
Expand All @@ -56,7 +56,7 @@ function processTheImageQueue()
{
processingTheImageQueue = false;

storage.set('cache', data);
storage.setThrottle('cache', data);
}

});
Expand Down
31 changes: 31 additions & 0 deletions scripts/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,36 @@ function push(key, item)
ejs.set(key, storageJson[key], function(error){});
}

var throttles = {};
var debounces = {};

// Improve save perfomance in places that do not require instantaneous save
async function setThrottle(key)
{
clearTimeout(throttles[key]);

throttles[key] = setTimeout(function(){

clearTimeout(debounces[key]);
debounces[key] = false;

ejs.set(key, storageJson[key], function(error){});

}, 300);

if(debounces[key] === undefined || debounces[key] === false)
{
debounces[key] = setTimeout(function(){

clearTimeout(throttles[key]);
debounces[key] = false;

ejs.set(key, storageJson[key], function(error){});

}, 3000);
}
}

var storageKeys = [];

for(let key in storageDefault)
Expand Down Expand Up @@ -563,6 +593,7 @@ module.exports = {
updateVar: updateVar,
setVar: updateVar,
set: update,
setThrottle: setThrottle,
update: update,
push: push,
storageJson: storageJson,
Expand Down

0 comments on commit 1a07d2d

Please sign in to comment.