Skip to content

Commit 235bc37

Browse files
committed
Simplified and opmtimized async / Promises.
1 parent e5bef1b commit 235bc37

File tree

5 files changed

+116
-79
lines changed

5 files changed

+116
-79
lines changed

package-lock.json

Lines changed: 69 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"make-dir": "^1.3.0",
3131
"markdownlint": "^0.8.1",
3232
"markdownlint-cli": "^0.8.1",
33-
"nw": "^0.31.4",
33+
"nw": "^0.31.5",
3434
"nw-builder": "^3.5.4",
3535
"replace-in-file": "^3.4.0",
3636
"rimraf": "^2.6.2"

src/cache/cache.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,16 @@ cwc.Cache.prototype.update = async function(version) {
8282
this.log_.info('Updating Cache to version', this.version);
8383
await this.database_.clear();
8484

85-
let promises = [];
8685
this.log_.info('Loading external frameworks ...');
87-
promises.push(this.loadFiles(cwc.framework.External));
86+
await this.loadFiles(cwc.framework.External);
8887

8988
this.log_.info('Loading internal frameworks ...');
90-
promises.push(this.loadFiles(cwc.framework.Internal));
89+
await this.loadFiles(cwc.framework.Internal);
9190

9291
this.log_.info('Loading Style Sheets ...');
93-
promises.push(this.loadFiles(cwc.framework.StyleSheet));
94-
95-
promises.push(this.database_.add('__version__', this.version));
92+
await this.loadFiles(cwc.framework.StyleSheet);
9693

97-
await Promise.all(promises);
94+
await this.database_.add('__version__', this.version);
9895
};
9996

10097

src/ui/builder.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ cwc.ui.Builder.prototype.decorateUI = function() {
282282
this.setProgressFunc('Prepare account support ...', this.prepareAccount);
283283
}
284284
this.setProgressFunc('Loading select screen ...', this.showSelectScreen);
285-
let startCwC = () => {
285+
this.setProgressFunc('Loading cache ...', this.loadCache).then(() => {
286286
// Done.
287287
this.setProgress('Starting Coding with Chrome', 100);
288288
this.loaded = true;
@@ -292,12 +292,8 @@ cwc.ui.Builder.prototype.decorateUI = function() {
292292
this.events_.clear();
293293
this.loadingScreen_.hideSecondsAfterStart(3000);
294294
resolve();
295-
};
296-
this.setProgressFunc('Loading cache ...', this.loadCache).then(() => {
297-
startCwC();
298295
}).catch((error) => {
299296
this.log_.error('Failed to load cache', error);
300-
startCwC();
301297
});
302298
});
303299
};

0 commit comments

Comments
 (0)