Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/filterListener.js

Issue 29935568: Issue 7096 - Make it possible to lazy initialize a filter's subscriptions (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Nov. 3, 2018, 9:19 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 /** 133 /**
134 * Notifies Matcher instances or ElemHide object about a new filter 134 * Notifies Matcher instances or ElemHide object about a new filter
135 * if necessary. 135 * if necessary.
136 * @param {Filter} filter filter that has been added 136 * @param {Filter} filter filter that has been added
137 */ 137 */
138 function addFilter(filter) 138 function addFilter(filter)
139 { 139 {
140 if (!(filter instanceof ActiveFilter) || filter.disabled) 140 if (!(filter instanceof ActiveFilter) || filter.disabled)
141 return; 141 return;
142 142
143 if (!filter.subscriptionsAdded)
Manish Jethani 2018/11/03 21:31:25 The subscriptions will already be added when the s
144 filterStorage.addSubscriptionsToFilter(filter);
145
143 let hasEnabled = false; 146 let hasEnabled = false;
144 let allowSnippets = false; 147 let allowSnippets = false;
145 for (let subscription of filter.subscriptions()) 148 for (let subscription of filter.subscriptions())
146 { 149 {
147 if (!subscription.disabled) 150 if (!subscription.disabled)
148 { 151 {
149 hasEnabled = true; 152 hasEnabled = true;
150 153
151 // Allow snippets to be executed only by the circumvention lists or the 154 // Allow snippets to be executed only by the circumvention lists or the
152 // user's own filters. 155 // user's own filters.
(...skipping 29 matching lines...) Expand all
182 * if necessary. 185 * if necessary.
183 * @param {Filter} filter filter that has been removed 186 * @param {Filter} filter filter that has been removed
184 */ 187 */
185 function removeFilter(filter) 188 function removeFilter(filter)
186 { 189 {
187 if (!(filter instanceof ActiveFilter)) 190 if (!(filter instanceof ActiveFilter))
188 return; 191 return;
189 192
190 if (!filter.disabled) 193 if (!filter.disabled)
191 { 194 {
195 if (!filter.subscriptionsAdded)
196 filterStorage.addSubscriptionsToFilter(filter);
197
192 let hasEnabled = false; 198 let hasEnabled = false;
193 for (let subscription of filter.subscriptions()) 199 for (let subscription of filter.subscriptions())
194 { 200 {
195 if (!subscription.disabled) 201 if (!subscription.disabled)
196 { 202 {
197 hasEnabled = true; 203 hasEnabled = true;
198 break; 204 break;
199 } 205 }
200 } 206 }
201 if (hasEnabled) 207 if (hasEnabled)
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 { 346 {
341 if (!subscription.disabled) 347 if (!subscription.disabled)
342 addFilters(subscription.filters); 348 addFilters(subscription.filters);
343 } 349 }
344 } 350 }
345 351
346 function onSave() 352 function onSave()
347 { 353 {
348 isDirty = 0; 354 isDirty = 0;
349 } 355 }
OLDNEW
« no previous file with comments | « lib/filterClasses.js ('k') | lib/filterStorage.js » ('j') | lib/filterStorage.js » ('J')

Powered by Google App Engine
This is Rietveld