fix: undefined on strings

This commit is contained in:
Jean-Baptiste Pasquier 2021-04-08 21:25:14 +02:00
parent 82e5b82572
commit ba25ac93a5
1 changed files with 25 additions and 23 deletions

View File

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