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

Side by Side Diff: lib/filterListener.js

Issue 5373553692114944: Issue #430 - Filter hit counters aren't cleared (Closed)
Patch Set: Created June 13, 2014, 9:12 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/ui.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 28 matching lines...) Expand all
39 /** 39 /**
40 * Increases on filter changes, filters will be saved if it exceeds 1. 40 * Increases on filter changes, filters will be saved if it exceeds 1.
41 * @type Integer 41 * @type Integer
42 */ 42 */
43 let isDirty = 0; 43 let isDirty = 0;
44 44
45 /** 45 /**
46 * This object can be used to change properties of the filter change listeners. 46 * This object can be used to change properties of the filter change listeners.
47 * @class 47 * @class
48 */ 48 */
49 let FilterListener = exports.FilterListener = 49 let FilterListener =
50 { 50 {
51 /** 51 /**
52 * Set to true when executing many changes, changes will only be fully applied after this variable is set to false again. 52 * Set to true when executing many changes, changes will only be fully applied after this variable is set to false again.
53 * @type Boolean 53 * @type Boolean
54 */ 54 */
55 get batchMode() 55 get batchMode()
56 { 56 {
57 return batchMode; 57 return batchMode;
58 }, 58 },
59 set batchMode(value) 59 set batchMode(value)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 229
230 flushElemHide(); 230 flushElemHide();
231 } 231 }
232 232
233 /** 233 /**
234 * Filter change listener 234 * Filter change listener
235 */ 235 */
236 function onFilterChange(action, filter, newValue, oldValue) 236 function onFilterChange(action, filter, newValue, oldValue)
237 { 237 {
238 if (action == "hitCount" || action == "lastHit") 238 if (action == "hitCount" && newValue == 0)
239 {
240 // Filter hits are being reset, make sure these changes are saved.
241 FilterListener.setDirty(0);
242 }
243 else if (action == "hitCount" || action == "lastHit")
239 FilterListener.setDirty(0.002); 244 FilterListener.setDirty(0.002);
240 else 245 else
241 FilterListener.setDirty(1); 246 FilterListener.setDirty(1);
242 247
243 if (action != "added" && action != "removed" && action != "disabled") 248 if (action != "added" && action != "removed" && action != "disabled")
244 return; 249 return;
245 250
246 if ((action == "added" || action == "removed") && filter.disabled) 251 if ((action == "added" || action == "removed") && filter.disabled)
247 { 252 {
248 // Ignore adding/removing of disabled filters 253 // Ignore adding/removing of disabled filters
(...skipping 19 matching lines...) Expand all
268 defaultMatcher.clear(); 273 defaultMatcher.clear();
269 ElemHide.clear(); 274 ElemHide.clear();
270 for (let subscription of FilterStorage.subscriptions) 275 for (let subscription of FilterStorage.subscriptions)
271 if (!subscription.disabled) 276 if (!subscription.disabled)
272 subscription.filters.forEach(addFilter); 277 subscription.filters.forEach(addFilter);
273 flushElemHide(); 278 flushElemHide();
274 } 279 }
275 else if (action == "save") 280 else if (action == "save")
276 isDirty = 0; 281 isDirty = 0;
277 } 282 }
OLDNEW
« no previous file with comments | « no previous file | lib/ui.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld