| Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 { | 136 { | 
| 137 let listenerFilters = changeListeners.get(page); | 137 let listenerFilters = changeListeners.get(page); | 
| 138 if (!listenerFilters) | 138 if (!listenerFilters) | 
| 139 { | 139 { | 
| 140 listenerFilters = Object.create(null); | 140 listenerFilters = Object.create(null); | 
| 141 changeListeners.set(page, listenerFilters); | 141 changeListeners.set(page, listenerFilters); | 
| 142 } | 142 } | 
| 143 return listenerFilters; | 143 return listenerFilters; | 
| 144 } | 144 } | 
| 145 | 145 | 
| 146 function addSubscription(subscription, message) | |
| 
 
Thomas Greiner
2017/09/29 16:39:18
Detail: The name "message" here is quite generic.
 
saroyanm
2017/09/29 16:58:56
Done.
 
 | |
| 147 { | |
| 148 subscription.disabled = false; | |
| 149 if ("title" in message) | |
| 
 
saroyanm
2017/09/29 14:35:17
Lack of this check were causing the unexpected beh
 
Thomas Greiner
2017/09/29 16:39:18
The URL is used as a fallback whenever there's no
 
saroyanm
2017/09/29 16:58:56
I see, thanks for the info.
 
 | |
| 150 subscription.title = message.title; | |
| 151 if ("homepage" in message) | |
| 152 subscription.homepage = message.homepage; | |
| 153 | |
| 154 FilterStorage.addSubscription(subscription); | |
| 155 if (subscription instanceof DownloadableSubscription && | |
| 
 
saroyanm
2017/09/29 14:35:17
Previously we were not checking if it's a Download
 
Thomas Greiner
2017/09/29 16:39:18
Acknowledged.
 
 | |
| 156 !subscription.lastDownload) | |
| 157 Synchronizer.execute(subscription); | |
| 158 } | |
| 159 | |
| 146 port.on("app.get", (message, sender) => | 160 port.on("app.get", (message, sender) => | 
| 147 { | 161 { | 
| 148 if (message.what == "issues") | 162 if (message.what == "issues") | 
| 149 { | 163 { | 
| 150 let subscriptionInit = require("subscriptionInit"); | 164 let subscriptionInit = require("subscriptionInit"); | 
| 151 let result = subscriptionInit ? subscriptionInit.reinitialized : false; | 165 let result = subscriptionInit ? subscriptionInit.reinitialized : false; | 
| 152 return {filterlistsReinitialized: result}; | 166 return {filterlistsReinitialized: result}; | 
| 153 } | 167 } | 
| 154 | 168 | 
| 155 if (message.what == "doclink") | 169 if (message.what == "doclink") | 
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 { | 338 { | 
| 325 if (message.key == "notifications_ignoredcategories") | 339 if (message.key == "notifications_ignoredcategories") | 
| 326 return NotificationStorage.toggleIgnoreCategory("*"); | 340 return NotificationStorage.toggleIgnoreCategory("*"); | 
| 327 | 341 | 
| 328 return Prefs[message.key] = !Prefs[message.key]; | 342 return Prefs[message.key] = !Prefs[message.key]; | 
| 329 }); | 343 }); | 
| 330 | 344 | 
| 331 port.on("subscriptions.add", (message, sender) => | 345 port.on("subscriptions.add", (message, sender) => | 
| 332 { | 346 { | 
| 333 let subscription = Subscription.fromURL(message.url); | 347 let subscription = Subscription.fromURL(message.url); | 
| 334 if ("title" in message) | |
| 335 subscription.title = message.title; | |
| 336 if ("homepage" in message) | |
| 337 subscription.homepage = message.homepage; | |
| 338 | |
| 339 if (message.confirm) | 348 if (message.confirm) | 
| 340 { | 349 { | 
| 350 if ("title" in message) | |
| 351 subscription.title = message.title; | |
| 352 if ("homepage" in message) | |
| 353 subscription.homepage = message.homepage; | |
| 354 | |
| 341 ext.showOptions(() => | 355 ext.showOptions(() => | 
| 342 { | 356 { | 
| 343 sendMessage("app", "addSubscription", subscription); | 357 sendMessage("app", "addSubscription", subscription); | 
| 344 }); | 358 }); | 
| 345 } | 359 } | 
| 346 else | 360 else | 
| 347 { | 361 { | 
| 348 subscription.disabled = false; | 362 addSubscription(subscription, message); | 
| 349 FilterStorage.addSubscription(subscription); | |
| 350 | |
| 351 if (subscription instanceof DownloadableSubscription && | |
| 352 !subscription.lastDownload) | |
| 353 Synchronizer.execute(subscription); | |
| 354 } | 363 } | 
| 355 }); | 364 }); | 
| 356 | 365 | 
| 357 port.on("subscriptions.get", (message, sender) => | 366 port.on("subscriptions.get", (message, sender) => | 
| 358 { | 367 { | 
| 359 let subscriptions = FilterStorage.subscriptions.filter((s) => | 368 let subscriptions = FilterStorage.subscriptions.filter((s) => | 
| 360 { | 369 { | 
| 361 if (message.ignoreDisabled && s.disabled) | 370 if (message.ignoreDisabled && s.disabled) | 
| 362 return false; | 371 return false; | 
| 363 if (s instanceof DownloadableSubscription && message.downloadable) | 372 if (s instanceof DownloadableSubscription && message.downloadable) | 
| (...skipping 24 matching lines...) Expand all Loading... | |
| 388 let subscription = Subscription.fromURL(message.url); | 397 let subscription = Subscription.fromURL(message.url); | 
| 389 if (subscription.url in FilterStorage.knownSubscriptions) | 398 if (subscription.url in FilterStorage.knownSubscriptions) | 
| 390 { | 399 { | 
| 391 if (subscription.disabled || message.keepInstalled) | 400 if (subscription.disabled || message.keepInstalled) | 
| 392 subscription.disabled = !subscription.disabled; | 401 subscription.disabled = !subscription.disabled; | 
| 393 else | 402 else | 
| 394 FilterStorage.removeSubscription(subscription); | 403 FilterStorage.removeSubscription(subscription); | 
| 395 } | 404 } | 
| 396 else | 405 else | 
| 397 { | 406 { | 
| 398 subscription.disabled = false; | 407 addSubscription(subscription, message); | 
| 399 subscription.title = message.title; | |
| 400 subscription.homepage = message.homepage; | |
| 401 FilterStorage.addSubscription(subscription); | |
| 402 if (!subscription.lastDownload) | |
| 403 Synchronizer.execute(subscription); | |
| 404 } | 408 } | 
| 405 }); | 409 }); | 
| 406 | 410 | 
| 407 port.on("subscriptions.update", (message, sender) => | 411 port.on("subscriptions.update", (message, sender) => | 
| 408 { | 412 { | 
| 409 let {subscriptions} = FilterStorage; | 413 let {subscriptions} = FilterStorage; | 
| 410 if (message.url) | 414 if (message.url) | 
| 411 subscriptions = [Subscription.fromURL(message.url)]; | 415 subscriptions = [Subscription.fromURL(message.url)]; | 
| 412 | 416 | 
| 413 for (let subscription of subscriptions) | 417 for (let subscription of subscriptions) | 
| 414 { | 418 { | 
| 415 if (subscription instanceof DownloadableSubscription) | 419 if (subscription instanceof DownloadableSubscription) | 
| 416 Synchronizer.execute(subscription, true); | 420 Synchronizer.execute(subscription, true); | 
| 417 } | 421 } | 
| 418 }); | 422 }); | 
| 419 })(this); | 423 })(this); | 
| OLD | NEW |