Skip to content

Commit

Permalink
v8.3.14-dev.33 Giveaway Extractor: optimize cache loading (close #1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael committed May 26, 2019
1 parent f3398ce commit 6010062
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"webpack-shell-plugin": "0.5.0",
"webpack-cli": "^3.1.0"
},
"devVersion": "8.3.14-dev.32",
"devVersion": "8.3.14-dev.33",
"homepage": "https://github.com/gsrafael01/ESGST",
"keywords": [
"esgst",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class Common extends Module {
const customPage = this.esgst.customPages[this.esgst.parameters.esgst];
if (customPage && customPage.check) {
await customPage.load();
} else {
} else if (!shared.esgst.parameters.esgst || shared.esgst.parameters.esgst !== `ge`) {
await this.endless_load(document, !this.esgst.parameters.esgst || this.esgst.parameters.esgst === `guide`);
}

Expand Down
18 changes: 14 additions & 4 deletions src/modules/Giveaways/GiveawayExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,19 @@ class GiveawaysGiveawayExtractor extends Module {
cacheWarning = common.createElements_v2(ge.popup.description, `beforeEnd`, [
[`div`, `These results were retrieved from the cache from ${common.getTimeSince(ge.cache[ge.cacheId].timestamp)} ago (${this.esgst.modules.generalAccurateTimestamp.at_formatTimestamp(ge.cache[ge.cacheId].timestamp)}). If you want to update the cache, you will have to extract again.`]
]);

createElements(ge.results, `beforeEnd`, [{
type: `div`
}]);

let html = ``;
let points = 0;
let total = 0;
for (const code of ge.cache[ge.cacheId].codes) {
if (total % 50 === 0) {
html = ``;
}

const giveaway = ge.cache[ge.cacheId].giveaways[code];
if (giveaway) {
html += giveaway.html;
Expand All @@ -381,6 +390,11 @@ class GiveawaysGiveawayExtractor extends Module {
} else {
window.open(`https://www.sgtools.info/giveaways/${code}`);
}

if (total % 50 === 0) {
ge.results.lastElementChild.insertAdjacentHTML(`beforeEnd`, html);
await shared.common.timeout(100);
}
}
this.esgst.modules.common.createElements(ge.progress, `inner`, [{
text: total,
Expand All @@ -389,10 +403,6 @@ class GiveawaysGiveawayExtractor extends Module {
text: ` giveaways extracted.`,
type: `node`
}]);
createElements(ge.results, `beforeEnd`, [{
type: `div`
}]);
ge.results.lastElementChild.insertAdjacentHTML(`beforeEnd`, html);
await endless_load(ge.results.lastElementChild, false, `ge`);
const items = [{
attributes: {
Expand Down

0 comments on commit 6010062

Please sign in to comment.