Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove dead code #788

Merged
merged 1 commit into from
Nov 29, 2024
Merged

chore: Remove dead code #788

merged 1 commit into from
Nov 29, 2024

Conversation

piotr-cz
Copy link
Contributor

@piotr-cz piotr-cz commented Nov 18, 2024

Description

At given point event.isExternal has already been evaluated to be undefined

if (typeof event.isExternal !== 'undefined') {

so it's value cannot be truthy.

Linked Issues

none

Additional Context

I'm just trying to understand how the client-side logic works

Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for vite-plugin-pwa-legacy ready!

Name Link
🔨 Latest commit 01d3788
🔍 Latest deploy log https://app.netlify.com/sites/vite-plugin-pwa-legacy/deploys/673baaa4a328580008e6e197
😎 Deploy Preview https://deploy-preview-788--vite-plugin-pwa-legacy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@piotr-cz piotr-cz changed the title Fix: Remove falsy condition fix: Remove falsy condition Nov 18, 2024
@piotr-cz piotr-cz changed the title fix: Remove falsy condition fix: Remove dead code Nov 18, 2024
@userquin
Copy link
Member

userquin commented Nov 18, 2024

The logic is in worbox window, it is not documented and it ss hard to test, yoi need 2 or more tabs and 2 browser instances. Then fire the update from the tabs and from the other instance: depending who installed/activated the new sw the flag May change.

I forgot to mention you need to await 1 minute between builds, the heuristic algorithmn used in workbox-window will give wrong flags in the event.

@piotr-cz
Copy link
Contributor Author

Here is the diff with comments:

  if (typeof event.isExternal !== 'undefined') {
    if (event.isExternal)
      showSkipWaitingPrompt()
    else
      !onNeedRefreshCalled && onOfflineReady?.()
  }
  else {
-   if (event.isExternal) // This is never truthy, because `typeof event.isExternal === 'undefined'` (see line 1)
-     window.location.reload()
-   else
      !onNeedRefreshCalled && onOfflineReady?.()
  }

@userquin userquin changed the title fix: Remove dead code chore: Remove dead code Nov 29, 2024
@userquin userquin merged commit 320a9c2 into vite-pwa:main Nov 29, 2024
4 checks passed
@piotr-cz piotr-cz deleted the patch-1 branch November 30, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants