1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2026-06-21 23:38:39 +00:00

feat(ui): optimize design of PWA update notification (#2757)

This commit is contained in:
Cotes Chung
2026-06-20 05:42:07 +08:00
committed by GitHub
parent 7496dd41fa
commit 5cc9dc66ac
36 changed files with 66 additions and 70 deletions
+4 -4
View File
@@ -8,9 +8,9 @@ if ('serviceWorker' in navigator) {
if (register) {
const swUrl = `${baseUrl}/sw.min.js`;
const notification = document.getElementById('notification');
const btnRefresh = notification.querySelector('.toast-body>button');
const popupWindow = Toast.getOrCreateInstance(notification);
const $notification = document.getElementById('notification');
const $btnUpdate = $notification.querySelector('[aria-label="Update"]');
const popupWindow = Toast.getOrCreateInstance($notification);
navigator.serviceWorker.register(swUrl).then((registration) => {
// Restore the update window that was last manually closed by the user
@@ -28,7 +28,7 @@ if ('serviceWorker' in navigator) {
});
});
btnRefresh.addEventListener('click', () => {
$btnUpdate.addEventListener('click', () => {
if (registration.waiting) {
registration.waiting.postMessage('SKIP_WAITING');
}