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

Delta Between Two Patch Sets: lib/notification.js

Issue 29370562: [adblockpluscore] Issue 4762 - Added "relentless" notification that shows up in intervals (Closed)
Left Patch Set: Changed not equal comparison Created Jan. 6, 2017, 2:35 p.m.
Right Patch Set: Adressed review comments Created Jan. 20, 2017, 10:25 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | test/notification.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 { 217 {
218 if (typeof notification.interval == "number") 218 if (typeof notification.interval == "number")
219 { 219 {
220 if (shown + notification.interval > Date.now()) 220 if (shown + notification.interval > Date.now())
221 continue; 221 continue;
222 } 222 }
223 else if (shown) 223 else if (shown)
224 continue; 224 continue;
225 } 225 }
226 226
227 if (Prefs.notifications_ignoredcategories.indexOf("*") != -1) 227 if (notification.type !== "relentless" && Prefs.notifications_ignoredcat egories.indexOf("*") != -1)
228 continue; 228 continue;
229 } 229 }
230 230
231 if (typeof url === "string" || notification.urlFilters instanceof Array) 231 if (typeof url === "string" || notification.urlFilters instanceof Array)
232 { 232 {
233 if (Prefs.enabled && typeof url === "string" && notification.urlFilters instanceof Array) 233 if (Prefs.enabled && typeof url === "string" && notification.urlFilters instanceof Array)
234 { 234 {
235 let host; 235 let host;
236 try 236 try
237 { 237 {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 * @param {String} id ID of the notification to be marked as shown 299 * @param {String} id ID of the notification to be marked as shown
300 */ 300 */
301 markAsShown: function(id) 301 markAsShown: function(id)
302 { 302 {
303 let now = Date.now(); 303 let now = Date.now();
304 let data = Prefs.notificationdata; 304 let data = Prefs.notificationdata;
305 305
306 if (data.shown instanceof Array) 306 if (data.shown instanceof Array)
307 { 307 {
308 let newShown = {}; 308 let newShown = {};
309 for (let old_id of data.shown) 309 for (let oldId of data.shown)
Felix Dahlke 2017/01/12 16:39:49 Nit: Camel case rather than underscore please :)
wspee 2017/01/16 13:51:12 Done.
310 newShown[old_id] = now; 310 newShown[oldId] = now;
311 data.shown = newShown; 311 data.shown = newShown;
312 } 312 }
313 313
314 if (typeof data.shown != "object") 314 if (typeof data.shown != "object")
315 data.shown = {}; 315 data.shown = {};
316 316
317 data.shown[id] = now; 317 data.shown[id] = now;
318 318
319 saveNotificationData(); 319 saveNotificationData();
320 }, 320 },
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 Prefs.notifications_showui = true; 419 Prefs.notifications_showui = true;
420 } 420 }
421 else if (index != -1 && forceValue !== true) 421 else if (index != -1 && forceValue !== true)
422 categories.splice(index, 1); 422 categories.splice(index, 1);
423 423
424 // HACK: JSON values aren't saved unless they are assigned a different objec t. 424 // HACK: JSON values aren't saved unless they are assigned a different objec t.
425 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories )); 425 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories ));
426 } 426 }
427 }; 427 };
428 Notification.init(); 428 Notification.init();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld