diff --git a/src/components/sw-toolbox.js b/src/components/sw-toolbox.js index 4012aa0..4b11fd0 100644 --- a/src/components/sw-toolbox.js +++ b/src/components/sw-toolbox.js @@ -10,31 +10,33 @@ if ('serviceWorker' in navigator) { let registration; const showSkipWaitingPrompt = (event) => { - Swal.fire({ - position: 'bottom-end', - backdrop: false, - title: "", - text: hubl.intl.t('serviceWorker.newUpdate') + ". " + hubl.intl.t('serviceWorker.wantToUpdate'), - imageUrl: hubl.client.logo || 'https://cdn.startinblox.com/logos/webp/hubl.webp', - imageAlt: hubl.client.name, - showCancelButton: true, - confirmButtonClass: 'button text-xsmall text-bold text-center reversed color-secondary bordered icon icon-check no-background-image', - cancelButtonClass: 'button text-xsmall text-bold text-center reversed color-primary bordered icon icon-exclamation no-background-image', - confirmButtonText: hubl.intl.t('serviceWorker.yes'), - cancelButtonText: hubl.intl.t('serviceWorker.no') - }).then((result) => { - if (result.isConfirmed) { - wb.addEventListener('controlling', (event) => { - window.location.reload(); - }); - - if (registration && registration.waiting) { - messageSW(registration.waiting, { - type: 'SKIP_WAITING' + if(hubl.intl.t('serviceWorker.newUpdate') != undefined) { + Swal.fire({ + position: 'bottom-end', + backdrop: false, + title: "", + text: hubl.intl.t('serviceWorker.newUpdate') + ". " + hubl.intl.t('serviceWorker.wantToUpdate'), + imageUrl: hubl.client.logo || 'https://cdn.startinblox.com/logos/webp/hubl.webp', + imageAlt: hubl.client.name, + showCancelButton: true, + confirmButtonClass: 'button text-xsmall text-bold text-center reversed color-secondary bordered icon icon-check no-background-image', + cancelButtonClass: 'button text-xsmall text-bold text-center reversed color-primary bordered icon icon-exclamation no-background-image', + confirmButtonText: hubl.intl.t('serviceWorker.yes'), + cancelButtonText: hubl.intl.t('serviceWorker.no') + }).then((result) => { + if (result.isConfirmed) { + wb.addEventListener('controlling', (event) => { + window.location.reload(); }); + + if (registration && registration.waiting) { + messageSW(registration.waiting, { + type: 'SKIP_WAITING' + }); + } } - } - }); + }); + } }; wb.addEventListener('waiting', showSkipWaitingPrompt);