Popup: actually show newly installed styles

fixup 5b0d8fb
This commit is contained in:
tophf 2015-05-08 03:48:09 +03:00
parent 0b821463c8
commit 60381603db

View File

@ -193,10 +193,14 @@ function handleUpdate(style) {
var styleElement = installed.querySelector("[style-id='" + style.id + "']"); var styleElement = installed.querySelector("[style-id='" + style.id + "']");
if (styleElement) { if (styleElement) {
installed.replaceChild(createStyleElement(style), styleElement); installed.replaceChild(createStyleElement(style), styleElement);
} else if (chrome.extension.getBackgroundPage().getApplicableSections(style, location.href).length) { } else {
// a new style for the current url is installed chrome.tabs.query({currentWindow: true, active: true}, function(tabs) {
document.getElementById("unavailable").style.display = "none"; if (tabs.length && chrome.extension.getBackgroundPage().getApplicableSections(style, tabs[0].url).length) {
installed.appendChild(createStyleElement(style)); // a new style for the current url is installed
document.getElementById("unavailable").style.display = "none";
installed.appendChild(createStyleElement(style));
}
});
} }
} }
@ -214,6 +218,7 @@ function handleDisableAll(disableAll) {
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) { chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
if (request.method == "updatePopup") { if (request.method == "updatePopup") {
switch (request.reason) { switch (request.reason) {
case "styleAdded":
case "styleUpdated": case "styleUpdated":
handleUpdate(request.style); handleUpdate(request.style);
break; break;