Updated service workers and disabled FCM SW IO-195
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import { AlertOutlined } from "@ant-design/icons";
|
||||
import { Button, notification } from "antd";
|
||||
import Dinero from "dinero.js";
|
||||
import i18n from "i18next";
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { Provider } from "react-redux";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import { PersistGate } from "redux-persist/integration/react";
|
||||
import AppContainer from "./App/App.container";
|
||||
import "./App/registerServiceWorker.component";
|
||||
import LoadingSpinner from "./components/loading-spinner/loading-spinner.component";
|
||||
import "./index.css";
|
||||
import { persistor, store } from "./redux/store";
|
||||
//import * as serviceWorker from "./serviceWorker"; //This is registered in a separate component to track notifications.
|
||||
import * as serviceWorker from "./serviceWorker";
|
||||
import "./translations/i18n";
|
||||
import "./utils/CleanAxios";
|
||||
|
||||
@@ -33,4 +35,35 @@ ReactDOM.render(
|
||||
document.getElementById("root")
|
||||
);
|
||||
|
||||
//serviceWorker.register();
|
||||
const onServiceWorkerUpdate = (registration) => {
|
||||
console.log("onServiceWorkerUpdate", registration);
|
||||
|
||||
const key = `open${Date.now()}`;
|
||||
const btn = (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={async () => {
|
||||
if (registration && registration.waiting) {
|
||||
await registration.unregister();
|
||||
// Makes Workbox call skipWaiting()
|
||||
registration.waiting.postMessage({ type: "SKIP_WAITING" });
|
||||
// Once the service worker is unregistered, we can reload the page to let
|
||||
// the browser download a fresh copy of our app (invalidating the cache)
|
||||
window.location.reload();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{i18n.t("general.actions.refresh")}
|
||||
</Button>
|
||||
);
|
||||
notification.open({
|
||||
icon: <AlertOutlined />,
|
||||
message: i18n.t("general.messages.newversiontitle"),
|
||||
description: i18n.t("general.messages.newversionmessage"),
|
||||
duration: 0,
|
||||
btn,
|
||||
key,
|
||||
});
|
||||
};
|
||||
|
||||
serviceWorker.register({ onUpdate: onServiceWorkerUpdate });
|
||||
|
||||
Reference in New Issue
Block a user