Skip to content

Commit

Permalink
refactor: don't use %raw in service worker registration
Browse files Browse the repository at this point in the history
  • Loading branch information
czabaj committed Jan 2, 2025
1 parent 70f2955 commit b8cd6ce
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions src/Main.res
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
LogUtils.initSentry()

let updateSW = ServiceWorker.registerSW({
onNeedRefresh: () => {
Toast.addMessage(
Info({
id: "sw-need-refresh",
message: <>
{React.string("Je k dispozici nová verze\xA0\xA0")}
<button
className={`${Styles.link.base}`} onClick={_ => %raw(`updateSW()`)} type_="button">
{React.string("Aktualizovat")}
</button>
</>,
}),
)
},
onOfflineReady: () => {
if !AppStorage.hasSeenOfflineModeReady() {
let updateSWRef = ref(ignore)
updateSWRef :=
ServiceWorker.registerSW({
onNeedRefresh: () => {
Toast.addMessage(
Info({
id: "sw-offline-ready",
message: React.string("Po přihlášení se stránka obejde i bez internetu."),
onClose: () => {
AppStorage.markSeenOfflineModeReady()
},
id: "sw-need-refresh",
message: <>
{React.string("Je k dispozici nová verze\xA0\xA0")}
<button
className={`${Styles.link.base}`}
onClick={_ => updateSWRef.contents()}
type_="button">
{React.string("Aktualizovat")}
</button>
</>,
}),
)
}
},
})
},
onOfflineReady: () => {
if !AppStorage.hasSeenOfflineModeReady() {
Toast.addMessage(
Info({
id: "sw-offline-ready",
message: React.string("Po přihlášení se stránka obejde i bez internetu."),
onClose: () => {
AppStorage.markSeenOfflineModeReady()
},
}),
)
}
},
})

open Reactfire

Expand Down

0 comments on commit b8cd6ce

Please sign in to comment.