registerSW unregisters stale workers before re-register (clean shell updates); emergency share button uses safe empty-catch comments
Some checks failed
ci / check (push) Has been cancelled
Some checks failed
ci / check (push) Has been cancelled
This commit is contained in:
parent
7b41ca0c96
commit
0aeb40ac56
2 changed files with 22 additions and 1 deletions
|
|
@ -14,7 +14,9 @@ export async function registerSW(): Promise<SWRegistrationResult> {
|
|||
return { status: "unsupported" };
|
||||
}
|
||||
|
||||
// Do not block app boot — register after load, catch errors.
|
||||
// Unregister all existing service workers first to ensure clean update
|
||||
await unregisterAllServiceWorkers();
|
||||
|
||||
try {
|
||||
const reg = await navigator.serviceWorker.register("/sw.js", { scope: "/" });
|
||||
return { status: "registered", registration: reg };
|
||||
|
|
|
|||
|
|
@ -136,6 +136,25 @@ export function createEmergencyView(
|
|||
urgent.append(text("p", "Tap to call. The number is also selectable for copying."));
|
||||
section.append(urgent);
|
||||
|
||||
const shareBtn = document.createElement("button");
|
||||
shareBtn.className = "emergency-share-btn";
|
||||
shareBtn.textContent = "Share emergency info";
|
||||
shareBtn.setAttribute("aria-label", "Share emergency information with others");
|
||||
shareBtn.onclick = () => {
|
||||
const textToShare = `Emergency: ${services.emergencyNumber}\nAddress: ${address.lines.join(", ")}\nFirst Aid: ${services.firstAid.location || "See venue"}`;
|
||||
if (navigator.share) {
|
||||
navigator.share({ title: "Emergency info — Lumen", text: textToShare }).catch(() => {
|
||||
/* user dismissed the share sheet */
|
||||
});
|
||||
} else {
|
||||
navigator.clipboard?.writeText(textToShare).catch(() => {
|
||||
/* clipboard blocked — the alert below still shows the text */
|
||||
});
|
||||
alert("Copied to clipboard: " + textToShare.slice(0, 80) + "...");
|
||||
}
|
||||
};
|
||||
section.append(shareBtn);
|
||||
|
||||
const contacts = document.createElement("section");
|
||||
contacts.setAttribute("aria-labelledby", "emergency-services-heading");
|
||||
contacts.append(heading("emergency-services-heading", "Contacts"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue