Skip to content

Commit 1a07d2d

Browse files
committed
Fix: Performance issues when generating some thumbnails
1 parent f409dbb commit 1a07d2d

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010

1111
- Delete bookmarks from the bookmark list [`3792f7d`](https://github.com/ollm/OpenComic/commit/3792f7db319cf885f398836aefe983e56fe5ef2a)
1212
- Save and show also the current folder progress apart from the main folder [`86f094b`](https://github.com/ollm/OpenComic/commit/86f094b7a216982ae7799950234be233113143e7)
13-
- Instead of the file name it shows the title of EPUB, PDF and Compressed Files with ComicInfo.xml
13+
- 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)
1414

1515
##### 🐛 Bug Fixes
1616

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

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

scripts/cache.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function processTheImageQueue()
3737
{
3838
processingTheImageQueue = false;
3939

40-
storage.set('cache', data);
40+
storage.setThrottle('cache', data);
4141
}
4242

4343
}).catch(function(){
@@ -56,7 +56,7 @@ function processTheImageQueue()
5656
{
5757
processingTheImageQueue = false;
5858

59-
storage.set('cache', data);
59+
storage.setThrottle('cache', data);
6060
}
6161

6262
});

scripts/storage.js

+31
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,36 @@ function push(key, item)
473473
ejs.set(key, storageJson[key], function(error){});
474474
}
475475

476+
var throttles = {};
477+
var debounces = {};
478+
479+
// Improve save perfomance in places that do not require instantaneous save
480+
async function setThrottle(key)
481+
{
482+
clearTimeout(throttles[key]);
483+
484+
throttles[key] = setTimeout(function(){
485+
486+
clearTimeout(debounces[key]);
487+
debounces[key] = false;
488+
489+
ejs.set(key, storageJson[key], function(error){});
490+
491+
}, 300);
492+
493+
if(debounces[key] === undefined || debounces[key] === false)
494+
{
495+
debounces[key] = setTimeout(function(){
496+
497+
clearTimeout(throttles[key]);
498+
debounces[key] = false;
499+
500+
ejs.set(key, storageJson[key], function(error){});
501+
502+
}, 3000);
503+
}
504+
}
505+
476506
var storageKeys = [];
477507

478508
for(let key in storageDefault)
@@ -563,6 +593,7 @@ module.exports = {
563593
updateVar: updateVar,
564594
setVar: updateVar,
565595
set: update,
596+
setThrottle: setThrottle,
566597
update: update,
567598
push: push,
568599
storageJson: storageJson,

0 commit comments

Comments
 (0)