Index: desktop-options.js |
=================================================================== |
--- a/desktop-options.js |
+++ b/desktop-options.js |
@@ -547,14 +547,17 @@ |
return null; |
} |
- function sendMessageHandleErrors(message, onSuccess) |
+ function sendMessageHandleErrors(message, onMessage) |
saroyanm
2018/01/23 15:26:06
Suggestion/detail: seems like onMessage is used fo
|
{ |
browser.runtime.sendMessage(message, (errors) => |
{ |
- if (errors.length > 0) |
- alert(errors.join("\n")); |
- else if (onSuccess) |
- onSuccess(); |
+ if (onMessage) |
+ { |
+ if (errors.length > 0) |
+ onMessage(errors); |
+ else |
+ onMessage(); |
+ } |
}); |
} |
@@ -648,14 +651,30 @@ |
}); |
break; |
case "save-custom-filters": |
+ const filters = E("custom-filters-raw"); |
sendMessageHandleErrors({ |
type: "filters.importRaw", |
- text: E("custom-filters-raw").value, |
+ text: filters.value, |
removeExisting: true |
}, |
- () => |
+ (errors) => |
{ |
- setCustomFiltersView("read"); |
+ if (errors) |
+ { |
+ filters.classList.add("warning"); |
+ E("custom-filters-edit-error").classList.add("warning"); |
saroyanm
2018/01/23 15:26:06
Suggestion: I think we can use "custom-filters" in
|
+ E("link-filters-on-edit-error").classList.add("visible"); |
saroyanm
2018/01/23 15:26:06
Note: If we agree on making this message persisten
|
+ const lines = filters.value.split(/\n+/); |
+ const info = errors.map(error => lines[error.lineno - 1]); |
saroyanm
2018/01/23 15:26:05
Note: As soon we introduce a new functionality whi
saroyanm
2018/01/23 15:26:06
I think would be great if we could return the filt
a.giammarchi
2018/01/23 15:43:18
yup, that's the "there's surely still stuff to do
a.giammarchi
2018/01/23 15:59:23
about this ... the error object doesn't offer much
saroyanm
2018/01/24 09:05:49
I think I couldn't well describe what I meant:
sen
|
+ const editFilters = E("custom-filters-edit-filters"); |
+ editFilters.textContent = info.join("\n"); |
saroyanm
2018/01/23 15:26:05
Adding all the elements as a textContent to div ma
a.giammarchi
2018/01/23 15:43:18
I either follow UI or I don't ... this comment is
saroyanm
2018/01/23 17:37:18
I missed that, I didn't review the CSS, my fault.
|
+ if (errors.length > 5) |
+ editFilters.classList.add("many"); |
+ } |
+ else |
+ { |
+ setCustomFiltersView("read"); |
+ } |
}); |
break; |
case "show-more-filters-section": |
@@ -755,6 +774,12 @@ |
updateCustomFiltersUi(); |
if (mode == "read") |
{ |
+ E("custom-filters-raw").classList.remove("warning"); |
saroyanm
2018/01/23 15:26:06
Note: As mentioned above we don't need to remove t
|
+ E("custom-filters-edit-error").classList.remove("warning"); |
+ E("link-filters-on-edit-error").classList.remove("visible"); |
+ const editFilters = E("custom-filters-edit-filters"); |
+ editFilters.textContent = ""; |
+ editFilters.classList.remove("many"); |
customFiltersElement.disabled = true; |
if (!customFiltersElement.value) |
{ |
@@ -918,10 +943,10 @@ |
{ |
setLinks("enable-acceptable-ads-description", link); |
}); |
- setElementText(E("tracking-warning-1"), "options_tracking_warning_1", |
+ setElementText(E("tracking-warning-1"), "options_tracking_warning_1", |
[getMessage("common_feature_privacy_title"), |
- getMessage("options_acceptableAds_ads_label")]); |
- setElementText(E("tracking-warning-3"), "options_tracking_warning_3", |
+ getMessage("options_acceptableAds_ads_label")]); |
+ setElementText(E("tracking-warning-3"), "options_tracking_warning_3", |
[getMessage("options_acceptableAds_privacy_label")]); |
getDocLink("privacy_friendly_ads", (link) => |
@@ -964,6 +989,7 @@ |
getDocLink("filterdoc", (link) => |
{ |
E("link-filters").setAttribute("href", link); |
+ E("link-filters-on-edit-error").setAttribute("href", link); |
}); |
getDocLink("subscriptions", (link) => |
@@ -1295,7 +1321,7 @@ |
updateSubscription(subscription); |
break; |
case "added": |
- let {url, recommended} = subscription; |
+ let {url} = subscription; |
// Handle custom subscription |
if (/^~user/.test(url)) |
{ |