• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

caleb531 / flip-book / 12128991451

02 Dec 2024 10:19PM UTC coverage: 27.304% (-0.08%) from 27.382%
12128991451

push

github

caleb531
Add "Updating..." message when update banner is clicked

72 of 100 branches covered (72.0%)

Branch coverage included in aggregate %.

0 of 7 new or added lines in 1 file covered. (0.0%)

2 existing lines in 1 file now uncovered.

405 of 1647 relevant lines covered (24.59%)

8.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/scripts/components/update-notification.jsx
1
import clsx from 'clsx';
×
NEW
2
import m from 'mithril';
×
UNCOV
3
import { registerSW } from 'virtual:pwa-register';
×
4

5
class UpdateNotificationComponent {
×
6
  // Use Vite PWA plugin to manage service worker updates (source:
7
  // <https://vite-pwa-org.netlify.app/guide/prompt-for-update.html#importing-virtual-modules>)
8
  oninit() {
×
9
    if (!navigator.serviceWorker) {
×
10
      return;
×
11
    }
×
12
    if (window.location.hostname === 'localhost' && !sessionStorage.getItem('sw')) {
×
13
      return;
×
14
    }
×
15
    this.isUpdateAvailable = false;
×
NEW
16
    this.isUpdating = false;
×
17
    this.updateSW = registerSW({
×
18
      onNeedRefresh: () => {
×
19
        this.isUpdateAvailable = true;
×
20
        m.redraw();
×
21
      }
×
22
    });
×
23
  }
×
24

25
  update() {
×
26
    if (this.updateSW) {
×
NEW
27
      this.isUpdating = true;
×
NEW
28
      m.redraw();
×
29
      this.updateSW();
×
30
    }
×
31
  }
×
32

33
  view() {
×
34
    return (
×
35
      <div
×
36
        className={clsx('update-notification', {
×
37
          'update-available': this.isUpdateAvailable
×
38
        })}
×
39
        onclick={() => this.update()}
×
40
      >
NEW
41
        <span className="update-notification-message">
×
NEW
42
          {this.isUpdating ? 'Updating...' : 'Update available! Click here to update.'}
×
NEW
43
        </span>
×
UNCOV
44
      </div>
×
45
    );
46
  }
×
47
}
×
48

49
export default UpdateNotificationComponent;
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc