| Index: new-options.js |
| =================================================================== |
| --- a/new-options.js |
| +++ b/new-options.js |
| @@ -393,18 +393,15 @@ |
| function updateLanguageCollections(subscription) |
| { |
| - if (subscription.recommended == "ads") |
|
Thomas Greiner
2016/06/16 17:08:38
Why did you move this check out of here? This func
saroyanm
2016/06/16 17:42:11
For code readability, we were calling this functio
Thomas Greiner
2016/06/17 13:48:03
Ok, what about getting rid of this function then a
saroyanm
2016/06/21 12:53:07
I think it's bit trickier than we thought,I've mer
Thomas Greiner
2016/06/22 10:08:04
Ok, I guess I assumed that `addItems()` would only
saroyanm
2016/06/22 12:31:59
I agree, but if we only fix that we will fix simpt
|
| + if (subscription.disabled) |
| { |
| - if (subscription.disabled) |
| - { |
| - collections.allLangs.addItems(subscription); |
| - collections.langs.removeItem(subscription); |
| - } |
| - else |
| - { |
| - collections.allLangs.removeItem(subscription); |
| - collections.langs.addItems(subscription); |
| - } |
| + collections.allLangs.addItems(subscription); |
| + collections.langs.removeItem(subscription); |
| + } |
| + else |
| + { |
| + collections.allLangs.removeItem(subscription); |
| + collections.langs.addItems(subscription); |
| } |
| } |
| @@ -432,19 +429,8 @@ |
| function updateSubscription(subscription) |
| { |
| - var knownSubscription = subscriptionsMap[subscription.url]; |
| - for (var property in subscription) |
| - { |
| - if (property == "title" && subscription.recommended) |
| - knownSubscription.originalTitle = subscription.title; |
| - else |
| - knownSubscription[property] = subscription[property]; |
| - } |
| - |
| for (var name in collections) |
| - collections[name].updateItem(knownSubscription); |
| - |
| - return knownSubscription; |
| + collections[name].updateItem(subscription); |
| } |
| function updateFilter(filter) |
| @@ -929,11 +915,24 @@ |
| function onSubscriptionMessage(action, subscription) |
| { |
| + if (subscription.url in subscriptionsMap) |
| + { |
| + var knownSubscription = subscriptionsMap[subscription.url]; |
| + for (var property in subscription) |
| + { |
| + if (property == "title" && knownSubscription.recommended) |
| + knownSubscription.originalTitle = subscription.title; |
| + else |
| + knownSubscription[property] = subscription[property]; |
| + } |
| + subscription = knownSubscription; |
| + } |
| switch (action) |
| { |
| case "disabled": |
| - subscription = updateSubscription(subscription); |
| - updateLanguageCollections(subscription); |
| + if (subscription.recommended == "ads") |
| + updateLanguageCollections(subscription); |
| + updateSubscription(subscription); |
| break; |
| case "downloading": |
| case "downloadStatus": |
| @@ -943,17 +942,16 @@ |
| updateSubscription(subscription); |
| break; |
| case "added": |
| - if (subscription.url in subscriptionsMap) |
| - subscription = updateSubscription(subscription); |
| + if (subscription.recommended == "ads") |
| + updateLanguageCollections(subscription); |
| + else if (subscription.url in subscriptionsMap) |
|
Thomas Greiner
2016/06/16 17:08:38
This else-if means that ad blocking subscriptions
saroyanm
2016/06/16 17:42:11
Yes the Advanced tab will be updated by the call b
Thomas Greiner
2016/06/23 14:54:29
Why isn't it updated by `addSubscription()` and `u
saroyanm
2016/06/23 16:27:12
We are also adding recommendations using "addSubsc
Thomas Greiner
2016/07/13 11:35:18
Ok, so the current behavior is:
- addSubscription:
saroyanm
2016/08/01 18:24:18
1. I've moved the call for updateLanguageCollectio
|
| + updateSubscription(subscription); |
| else |
| addSubscription(subscription); |
| - |
| + |
|
Thomas Greiner
2016/06/16 17:08:38
Coding style: Trailing white space.
saroyanm
2016/06/22 12:31:59
Done.
|
| collections.filterLists.addItems(subscription); |
| - updateLanguageCollections(subscription); |
| break; |
| case "removed": |
| - var knownSubscription = subscriptionsMap[subscription.url]; |
| - |
| if (subscription.url == acceptableAdsUrl || subscription.recommended) |
| { |
| subscription.disabled = true; |
| @@ -961,10 +959,10 @@ |
| } |
| else |
| { |
| - collections.custom.removeItem(knownSubscription); |
| + collections.custom.removeItem(subscription); |
| delete subscriptionsMap[subscription.url]; |
| } |
| - collections.filterLists.removeItem(knownSubscription); |
| + collections.filterLists.removeItem(subscription); |
| break; |
| } |