From a53eaddb9ece1e6e869eb2ba279d379313f80408 Mon Sep 17 00:00:00 2001 From: pixelstrolch Date: Mon, 26 Jul 2021 22:01:52 +0200 Subject: [PATCH] ServiceWorker update message --- gatsby-browser.js | 10 ++++++++++ i18n/de.json | 3 ++- i18n/en.json | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gatsby-browser.js b/gatsby-browser.js index be5981ea..919aaa18 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -2,3 +2,13 @@ import "./src/styles/reset.css" import "./src/styles/global.module.css" import "./src/styles/accessibility.css" import "./src/styles/general.css" +import { useIntl } from "react-intl" + +export const onServiceWorkerUpdateReady = () => { + const answer = window.confirm( + useIntl.formatMessage({ id: "sw.outdated" }) + ) + if (answer === true) { + window.location.reload() + } +} \ No newline at end of file diff --git a/i18n/de.json b/i18n/de.json index 44c1945b..01c073f7 100644 --- a/i18n/de.json +++ b/i18n/de.json @@ -58,5 +58,6 @@ "error.description": "Oh nein, irgendetwas ist schief gegangen. Die aufgerufene Seite scheint nicht zu existieren. Vielleicht wurde sie gelöscht oder verschoben.", "error.dog": "Traurig aussehnder Hund trägt eine Jeansjacke.", "github.icon": "Github Logo", - "github.edit": "Diesen Beitrag verbessern" + "github.edit": "Diesen Beitrag verbessern", + "sw.outdated": "Diese Webapp wurde aktualisiert. Willst du neu laden um die neuste Version zu sehen?" } \ No newline at end of file diff --git a/i18n/en.json b/i18n/en.json index 805faeec..3deed113 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -58,5 +58,6 @@ "error.description": "Oh no, something went wrong. The requested page doesn't seem to exist. Maybe it has been deleted or moved.", "error.dog": "Sad looking dog wears a jeans jacket.", "github.icon": "Github Logo", - "github.edit": "Improve this post" + "github.edit": "Improve this post", + "sw.outdated": "This web app has been updated. Reload to display the latest version?" } \ No newline at end of file