Skip to content

Commit 52b153f

Browse files
authoredJun 21, 2023
Merge pull request #2221 from AdaptiveConsulting/chore/update-modal-render
Chore/update modal render
2 parents 7b3c00b + 4b3ed6c commit 52b153f

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed
 

‎src/client/src/App.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export async function initApp() {
2727

2828
const container = document.getElementById("root")
2929
const root = createRoot(container as HTMLElement)
30+
3031
root.render(
3132
<StrictMode>
3233
<GlobalStyle />

‎src/client/src/Web/cacheUpdateModal.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ReactDOM from "react-dom"
1+
import { createRoot } from "react-dom/client"
22
import styled from "styled-components"
33

44
import { Modal } from "@/components/Modal"
@@ -28,7 +28,11 @@ export const showCacheUpdateModal = () => {
2828
const updateRoot = document.createElement("div")
2929
document.body.appendChild(updateRoot)
3030

31-
ReactDOM.render(
31+
const root = createRoot(updateRoot)
32+
33+
console.log("Showing service worker modal")
34+
35+
root.render(
3236
<ThemeProvider>
3337
<Modal title="New updates are available" shouldShow>
3438
<p>Reload the page to see them.</p>
@@ -47,6 +51,5 @@ export const showCacheUpdateModal = () => {
4751
</Buttons>
4852
</Modal>
4953
</ThemeProvider>,
50-
updateRoot,
5154
)
5255
}

‎src/client/src/main.ts

+4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ export const getMainApp: () => React.FC = () => {
1616
// could be a disaster
1717
// Wait for our async chunks to be loaded, then skip waiting phase and show
1818
// the user a modal informing them that there are new updates available
19+
20+
console.log("Service worker on update")
21+
1922
Promise.all([
2023
AnalyticsCoreDeferred,
2124
LiveRatesCoreDeferred,
2225
TradesCoreDeferred,
2326
]).then(() => {
27+
console.log("Deferred components resolved, sending skip message")
2428
registration.waiting?.postMessage({ type: "SKIP_WAITING" })
2529
showCacheUpdateModal()
2630
})

0 commit comments

Comments
 (0)
Please sign in to comment.