| LEFT | RIGHT |
| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 filterNotifier.emit("subscription.removed", subscription); | 190 filterNotifier.emit("subscription.removed", subscription); |
| 191 } | 191 } |
| 192 | 192 |
| 193 /** | 193 /** |
| 194 * Replaces the list of filters in a subscription with a new list. | 194 * Replaces the list of filters in a subscription with a new list. |
| 195 * @param {Subscription} subscription The subscription to be updated. | 195 * @param {Subscription} subscription The subscription to be updated. |
| 196 * @param {Array.<Filter>} filters The new list of filters. | 196 * @param {Array.<Filter>} filters The new list of filters. |
| 197 */ | 197 */ |
| 198 updateSubscriptionFilters(subscription, filters) | 198 updateSubscriptionFilters(subscription, filters) |
| 199 { | 199 { |
| 200 disconnectSubscriptionFilters(subscription); | |
| 201 | |
| 202 let oldFilters = [...subscription.filters()]; | 200 let oldFilters = [...subscription.filters()]; |
| 201 disconnectSubscriptionFilters(subscription, oldFilters); |
| 203 subscription.clearFilters(); | 202 subscription.clearFilters(); |
| 203 |
| 204 for (let filter of filters) | 204 for (let filter of filters) |
| 205 subscription.addFilter(filter); | 205 subscription.addFilter(filter); |
| 206 | 206 |
| 207 connectSubscriptionFilters(subscription, filters); | 207 connectSubscriptionFilters(subscription, filters); |
| 208 |
| 208 filterNotifier.emit("subscription.updated", subscription, oldFilters); | 209 filterNotifier.emit("subscription.updated", subscription, oldFilters); |
| 209 } | 210 } |
| 210 | 211 |
| 211 /** | 212 /** |
| 212 * Adds a user-defined filter to the storage. | 213 * Adds a user-defined filter to the storage. |
| 213 * @param {Filter} filter | 214 * @param {Filter} filter |
| 214 * @param {?SpecialSubscription} [subscription] The subscription that the | 215 * @param {?SpecialSubscription} [subscription] The subscription that the |
| 215 * filter should be added to. | 216 * filter should be added to. |
| 216 * @param {number} [position] The position within the subscription at which | 217 * @param {number} [position] The position within the subscription at which |
| 217 * the filter should be added. If not specified, the filter is added at the | 218 * the filter should be added. If not specified, the filter is added at the |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 * subscription is disconnected from its own filters. | 676 * subscription is disconnected from its own filters. |
| 676 */ | 677 */ |
| 677 function disconnectSubscriptionFilters(subscription, filters) | 678 function disconnectSubscriptionFilters(subscription, filters) |
| 678 { | 679 { |
| 679 if (!filterStorage.knownSubscriptions.has(subscription.url)) | 680 if (!filterStorage.knownSubscriptions.has(subscription.url)) |
| 680 return; | 681 return; |
| 681 | 682 |
| 682 for (let filter of filters || subscription.filters()) | 683 for (let filter of filters || subscription.filters()) |
| 683 filter.removeSubscription(subscription); | 684 filter.removeSubscription(subscription); |
| 684 } | 685 } |
| LEFT | RIGHT |