Skip to content

Commit

Permalink
Add "Updating..." message when update banner is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed Dec 2, 2024
1 parent e4945e5 commit e29f631
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/components/update-notification.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import m from 'mithril';
import clsx from 'clsx';
import m from 'mithril';
import { registerSW } from 'virtual:pwa-register';

class UpdateNotificationComponent {
Expand All @@ -13,6 +13,7 @@ class UpdateNotificationComponent {
return;
}
this.isUpdateAvailable = false;
this.isUpdating = false;
this.updateSW = registerSW({
onNeedRefresh: () => {
this.isUpdateAvailable = true;
Expand All @@ -23,6 +24,8 @@ class UpdateNotificationComponent {

update() {
if (this.updateSW) {
this.isUpdating = true;
m.redraw();
this.updateSW();
}
}
Expand All @@ -35,7 +38,9 @@ class UpdateNotificationComponent {
})}
onclick={() => this.update()}
>
<span className="update-notification-message">Update available! Click here to update.</span>
<span className="update-notification-message">
{this.isUpdating ? 'Updating...' : 'Update available! Click here to update.'}
</span>
</div>
);
}
Expand Down

0 comments on commit e29f631

Please sign in to comment.