Fix: install error when live-reload is disabled

This commit is contained in:
eight 2017-10-04 16:32:44 +08:00
parent 2912a53729
commit 6636d3382b

View File

@ -148,13 +148,7 @@
updateMeta(result);
if (liveReload) {
port.postMessage({method: 'liveReloadStart'});
}
$('.live-reload').addEventListener('change', () => {
const method = 'liveReload' + (liveReload ? 'Start' : 'Stop');
port.postMessage({method});
});
window.dispatchEvent(new CustomEvent('installed'));
})
.catch(err => {
alert(chrome.i18n.getMessage('styleInstallFailed', String(err)));
@ -234,6 +228,15 @@
} else {
setLiveReload.addEventListener('change', () => {
liveReload = setLiveReload.checked;
if (installed) {
const method = 'liveReload' + (liveReload ? 'Start' : 'Stop');
port.postMessage({method});
}
});
window.addEventListener('installed', () => {
if (liveReload) {
port.postMessage({method: 'liveReloadStart'});
}
});
}
}