New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 3241 - Make filter list URL configurable in devbuilds #30
Conversation
Merge with Eyeo upstream
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
Sync with Eyeo
@@ -804,6 +845,36 @@ | |||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AdblockPlusSafariTests/Pods-AdblockPlusSafariTests-resources.sh\"\n"; | |||
showEnvVarsInLog = 0; | |||
}; | |||
83C19D903DD1D9F927CBD253 /* Copy Pods Resources */ = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, how I interpret this is, XCode got upgraded in the mean time and there are some pods related changes happening because of that? Could we put these in a separate commit? No need for an issue, just something like: "Noissue - XCode project file updates" would do. Then I can merge that one first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? I might understand what you asking but I am afraid that I am not able to split this commit to two standalone working parts. I can move xcode project file to different commit, and append this commit to this pull request. In that case you would have to pull both commits to be able to build it properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would suffice, ideally it'd be a separate pull request.
@dedecej Did you notice my comment here? |
@"easylist+exceptionrules_content_blocker.json" | ||
}; | ||
|
||
for (NSString *defaultFilterListName in defaultFilterListsFileNames) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided, that it would be more convenient to map filter lists by names rather then urls (which can be changed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of doc lines explaining the migration transformation would be handy
Sync with Eyeo
Sync with Eyeo
|
||
@implementation AdblockPlus (Extension) | ||
|
||
- (NSURL *__nullable)activeFilterListsURL | ||
{ | ||
NSString *fileName; | ||
NSString *filename; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the rename, isn't fileName
how we normally capitalise this in the code base? Assuming Apple's coding style doesn't cover this case, I suggest we stay consistent with the rest of the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, I probably forgot about it.
Alright, starting on this one. Had a quick look and left some superficial comments. Will take a closer look tomorrow. |
Sync with Eyeo
337d821
to
797b501
Compare
@fhd: Rebased and updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only bigger issue is the hardcoded tableviewdatasource index shifting magic. And maybe the asserts.
@@ -64,7 +66,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N | |||
{ | |||
if ([keyPath isEqualToString:NSStringFromSelector(@selector(enabled))]) { | |||
self.blockingEnablingSwitch.on = self.adblockPlus.enabled; | |||
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone]; | |||
[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)] withRowAnimation:UITableViewRowAnimationNone]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An unfortunate binding of momentary design to hardcoded numbers. Someone will forget to update this when/if the design changes around. Like when a new section is inserted between. If such inserted section is NOT to be disabled on ABP toggle, then Range will be a wrong tool altogether. Any idea of how to make this programmatically safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do something, but unfortunately I cannot do more. It is possible to append any information to section in designer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this is basically Massive View Controller inception, so wrapping the index arithmetic away in a separate class would be good. The pluses and minuses should not be scattered across the controller. But this is already 50% better than the original hardcode, so let's do the other 50% when there is another UI requirement.
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | ||
{ | ||
return [super tableView:tableView numberOfRowsInSection:section] + (section == 0 ? 1 : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded design again. section == 0 should be at least a declared constant "which section needs the section offseting magic".
cell.textLabel.enabled = enabled; | ||
return cell; | ||
} else { | ||
return [super tableView:tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row - 1 inSection:0]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using correctedIndexPath here?
@property (nonatomic, strong, nullable) NSString *version; | ||
|
||
@property (nonatomic) BOOL userTriggered; | ||
@property (nonatomic) BOOL downloaded; | ||
@property (nonatomic) BOOL updating; | ||
@property (nonatomic) BOOL lastUpdateFailed; | ||
@property (nonatomic) NSUInteger taskIdentifier; | ||
@property (nonatomic) NSUInteger updatingGroupId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a clueless novice to the ABP code, i would like to have one line explanation of what is this number for. Task identifier would be nice to have explained too.
return self; | ||
} | ||
|
||
- (NSDictionary *)dictionary | ||
{ | ||
NSAssert(self.fileName, @"Filename must be set!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assert will do nothing on release run. Is this really just a debug sanity check? Are the asserts always true on release? If not, what will the function produce?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not happen. FilterList is create only from special dictionary, and that dictionary is not accessed from outside.
} | ||
} | ||
|
||
if (!fileName) { | ||
fileName = @"empty.json"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be declared constant. It is used in multiple places.
@fhd LGTM |
7ac44ee
to
9339f46
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally managed to take a closer look. Looks good, some minor comments.
|
||
for (NSString *defaultFilterListName in defaultFilterListsFileNames) { | ||
NSString *defaultFilterListFileName = defaultFilterListsFileNames[defaultFilterListName]; | ||
for (NSString *filterListName in filterListsVersion1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How I see it, filterListName
actually contains the filter list URL - so how about filterListUrl
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
for (NSString *filterListName in filterListsVersion1) { | ||
NSDictionary *filterList = filterListsVersion1[filterListName]; | ||
if ([filterList[@"filename"] isEqualToString:defaultFilterListFileName]) { | ||
NSMutableDictionary *modifiedFilterList = [filterList mutableCopy]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why copy filterList
and then modify it? Looks to me as if it would be cleaner and less code if we create a fresh object. Or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case I need to copy all properties from old filter list
_filterLists = filterListsVersion2; | ||
|
||
} else { | ||
// No filter lists was loaded, use default filter lists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we don't need an empty block just for this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
{ | ||
if (section == AdblockPlusControllerSectionDefault) { | ||
return [super tableView:tableView numberOfRowsInSection:section] + 1; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Another else
after return
, see above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
NSDate *lastUpdate = [self.adblockPlus.filterLists[self.adblockPlus.activeFilterListName] lastUpdate]; | ||
if (lastUpdate) { | ||
return [NSString stringWithFormat:defaultTitle, [self.dateFormatter stringFromDate:lastUpdate]]; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Another else
after return
, see above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
NSString *url = [NSUserDefaults.standardUserDefaults stringForKey:customFilterListKey]; | ||
if ([url length] == 0) { | ||
return customFilterListUrl; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Another else
after return
, see above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
- (NSAttributedString *)footerTitleForFilterList:(FilterList *)filterList | ||
{ | ||
if (filterList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block has a few else
after return
- I think the code can be simplified a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
{ | ||
if (!self.defaultFilterListEnabled && [self.filterLists[CustomFilterListName] downloaded]) { | ||
return CustomFilterListName; | ||
} else if (self.acceptableAdsEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We typically avoid else
after return
- it's redundant. But I wouldn't insist. Same goes for the other occurrences I pointed out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
if (indexPath.section == AdblockPlusControllerSectionDefault && indexPath.row > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block has a few else
after return
- I think the code can be simplified a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
updated = updated || (!lastUpdate && currentLastUpdate) || (currentLastUpdate && [currentLastUpdate compare:lastUpdate] == NSOrderedDescending); | ||
updated = updated || (!lastUpdate && !!currentLastUpdate) || (!!currentLastUpdate && [currentLastUpdate compare:lastUpdate] == NSOrderedDescending); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add the !!
here? I don't think it changes the behaviour of this expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
LGTM, I'll merge this. |
Merged, thanks! d468b47 |
Related to Issue 3241.