Skip to content

Commit

Permalink
Keep spinner hidden by default unless first time load
Browse files Browse the repository at this point in the history
  • Loading branch information
dmanjunath committed Oct 21, 2024
1 parent 0bd5659 commit df5de85
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/landing-page/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
<body class="hidden">
<div id="content">
<div class="logo">
<img id="logo" class="logo__image" src="/earthfast/images/earth-fast-logo.svg" alt="Earth Fast">
Expand All @@ -24,11 +24,7 @@ <h2 class="logo__title">EarthFast</h2>
</div>

<script>
const showSpinner = localStorage.getItem('showSpinner') !== 'false';
if (!showSpinner) {
document.getElementsByTagName('body')[0].style.backgroundColor = 'transparent';
document.getElementById('content').classList.add('hidden');
}
const showSpinner = false //localStorage.getItem('showSpinner') !== 'false';
const serviceWorker = '/earthfast-sw.js';

function fail(message) {
Expand Down Expand Up @@ -106,11 +102,16 @@ <h2 class="logo__title">EarthFast</h2>
// In this case we'll never get an INITIALIZED message, so a reload needs to be triggered
// manually. Since the service worker is active, we know the onFetch handler is installed
// and will be responsible for serving the reload request.

// if the service worker exists but the page was hard refreshe
if (reg.active) {
console.log('Active service worker found, reloading page');
reloadAfterWallTime(500);
reloadAfterWallTime(0);
} else {
// Wait for the service worker to become active
// first time loading the page, show loading spinner
if (showSpinner) {
document.body.classList.remove('hidden');
}
reg.addEventListener('updatefound', () => {
const newWorker = reg.installing;
newWorker.addEventListener('statechange', () => {
Expand Down

0 comments on commit df5de85

Please sign in to comment.