Fix: stop live-reload and refresh the page when style is removed

This commit is contained in:
eight 2017-09-19 08:41:40 +08:00
parent 0852b56ce4
commit 2b6404cb11

View File

@ -189,6 +189,16 @@ function initLiveReload(sourceLoader) {
watcher.start(); watcher.start();
} }
}); });
chrome.runtime.onMessage.addListener(request => {
if (request.method === 'styleDeleted') {
if (installed && installed.id === request.id) {
installed = null;
watcher.stop();
$('.live-reload-checkbox').checked = false;
location.reload();
}
}
});
$('.actions').appendChild($element({tag: 'label', className: 'live-reload', appendChild: [ $('.actions').appendChild($element({tag: 'label', className: 'live-reload', appendChild: [
$element({tag: 'input', type: 'checkbox', className: 'live-reload-checkbox'}), $element({tag: 'input', type: 'checkbox', className: 'live-reload-checkbox'}),
$element({tag: 'span', textContent: t('liveReloadLabel')}) $element({tag: 'span', textContent: t('liveReloadLabel')})