Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unregister old serviceworkers manualy #5222

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/assets/javascripts/coding_scratchpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
showButton.classList.remove("hidden");
showButton.addEventListener("click", async function () {
if (!papyros) { // Only create Papyros once per session, but only when required
// Papyros registers a service worker on a specific path
// We used to do this on a different path
// So we need to unregister old serviceworkers manually as these won't get overwritten
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (const registration of registrations) {
registration.unregister();

Check warning on line 36 in app/assets/javascripts/coding_scratchpad.ts

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/coding_scratchpad.ts#L36

Added line #L36 was not covered by tests
}
});

papyros = new Papyros(
{
programmingLanguage: Papyros.toProgrammingLanguage(programmingLanguage),
Expand Down