[web] remove unnecessary awaits from flutter.js#130204
[web] remove unnecessary awaits from flutter.js#130204auto-submit[bot] merged 6 commits intoflutter:masterfrom
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
test-exempt: code refactor with no semantic change |
There was a problem hiding this comment.
This looks correct to me. @ditman can you think of a good way to test this? NVM, this already has a test exemption.
| async _getNewServiceWorker(serviceWorkerRegistrationPromise) { | ||
| const reg = await serviceWorkerRegistrationPromise; | ||
|
|
||
| _getNewServiceWorker(reg) { |
There was a problem hiding this comment.
Can you substitute a more descriptive name
| _getNewServiceWorker(reg) { | |
| _getNewServiceWorker(serviceWorkerRegistration) { |
There was a problem hiding this comment.
Yeah, I just didn't want to rename existing usages of the reg variable below
There was a problem hiding this comment.
Should I also rename serviceWorker to the latestServiceWorker in _waitForServiceWorkerActivation function?
I don't like that this function currently (in my PR) has meaningless const serviceWorker = latestServiceWorker; line
There was a problem hiding this comment.
Or it can be the other way, latestServiceWorker -> serviceWorker
There was a problem hiding this comment.
oh yeah, we don't need that extra assignment now that we don't have an await.
ditman
left a comment
There was a problem hiding this comment.
Thanks for fine-tuning this! However this will conflict with your other PR where you fix the global serviceWorkerVersion variable :)
packages/flutter_tools/lib/src/web/file_generators/js/flutter.js
Outdated
Show resolved
Hide resolved
packages/flutter_tools/lib/src/web/file_generators/js/flutter.js
Outdated
Show resolved
Hide resolved
| if (!serviceWorker) { | ||
| return Promise.reject( | ||
| new Error("Cannot activate a null service worker!") | ||
| ); | ||
| throw new Error("Cannot activate a null service worker!"); | ||
| } else { | ||
| console.debug("Service worker already active."); | ||
| return Promise.resolve(); | ||
| return; | ||
| } |
|
|
|
@p-mazhnik this is independent of #130206. How about we get this one landed, and then have 130206 updated on top of this change? |
|
@ditman sounds good, let's do this way! |
|
OK @p-mazhnik this has immediately landed, you should be able of rebasing #130206 whenever it's convenient to you! |
Fixed types for `_getNewServiceWorker` and `_waitForServiceWorkerActivation` functions. These functions currently expect a Promise as an argument, but we're actually passing in an already resolved value: ```js .then(this._getNewServiceWorker) .then(this._waitForServiceWorkerActivation); ```
Fixed types for
_getNewServiceWorkerand_waitForServiceWorkerActivationfunctions.These functions currently expect a Promise as an argument, but we're actually passing in an already resolved value:
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.