🐛 Corrige la disparition du widget covid quand on quitte la page

pull/1187/head
Maxime Quandalle 2020-11-02 15:44:55 +01:00
parent 622d58828d
commit d960b1da20
1 changed files with 13 additions and 7 deletions

View File

@ -16,8 +16,11 @@ declare global {
StonlyWidget?: {
open: () => void
close: () => void
toggle: () => void
launcherShow: () => void
launcherHide: () => void
startURLWatcher: () => void
stopURLWatcher: () => void
}
}
}
@ -28,15 +31,18 @@ export default function ChômagePartiel() {
if (inIframe) {
return
}
const script = document.createElement('script')
window.STONLY_WID = '0128ae02-6780-11ea-ac13-0a4250848ba4'
script.src = 'https://stonly.com/js/widget/stonly-widget.js'
script.async = true
document.body.appendChild(script)
window.StonlyWidget?.launcherShow()
if (!window.StonlyWidget) {
const script = document.createElement('script')
window.STONLY_WID = '0128ae02-6780-11ea-ac13-0a4250848ba4'
script.src = 'https://stonly.com/js/widget/stonly-widget.js'
script.async = true
document.body.appendChild(script)
} else {
window.StonlyWidget?.launcherShow()
}
return () => {
window.StonlyWidget?.stopURLWatcher()
window.StonlyWidget?.launcherHide()
document.body.removeChild(script)
}
}, [inIframe])
return (