-
Notifications
You must be signed in to change notification settings - Fork 91
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
fix wikimedia photos #3278
fix wikimedia photos #3278
Conversation
sync cm_place url with android;
self.location.latitude, | ||
self.location.longitude, | ||
[OAIAPHelper isPaidVersion] ? @"paid" : @"free", | ||
(preferredLang && preferredLang.length > 0 ? [@"&lang=" stringByAppendingString:preferredLang] : @""), |
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.
It's better not to use two ternary operators in one condition
_wikiCardsReady = YES; | ||
[self sendNearbyOtherImagesRequest:cards]; | ||
}]; | ||
[self sendNearbyOtherImagesRequest:[NSMutableArray array]]; |
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.
retain cycle ?
Sources/Helpers/OAWikiImageHelper.h
Outdated
@@ -15,6 +15,10 @@ | |||
#define CM_LIMIT @"&cmlimit=500" | |||
#define FORMAT_JSON @"&format=json" | |||
#define IMAGE_BASE_URL @"https://commons.wikimedia.org/wiki/Special:FilePath/" | |||
#define USE_OSMAND_WIKI_API YES | |||
#define OSMAND_API_ENDPOINT @"https://osmand.net/api/" |
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.
don't use #define. it is not type-safe. static NSString* const OSMAND_API_ENDPOINT = @"https://osmand.net/api/";
- (OAWikiImage *)getOsmandApiWikiImage:(NSString *)imageUrl | ||
{ | ||
NSString *url = [imageUrl stringByRemovingPercentEncoding]; | ||
NSString *imageHiResUrl = [url stringByReplacingOccurrencesOfString:@" " withString:@"_"]; |
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.
imageHiResUrl - Interesting name:)
Sources/Helpers/OAWikiImageHelper.mm
Outdated
{ | ||
url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; | ||
NSURL *urlObj = [[NSURL alloc] initWithString:url]; | ||
NSURLSession *aSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; |
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.
*session
Sources/Helpers/OAWikiImageHelper.mm
Outdated
} | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
[cards addObjectsFromArray:resultCards]; | ||
(byCategory ? _wikimediaCardsReady : _wikidataCardsReady) = YES; |
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.
Replace duplicate checks with 'if byCategory'.
NSURLSession *aSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; | ||
[[aSession dataTaskWithURL:urlObj completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { | ||
NSMutableArray<OAAbstractCard *> *resultCards = [NSMutableArray array]; | ||
if (((NSHTTPURLResponse *)response).statusCode == 200) |
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.
Maybe we should add error logging to the log output?
Sources/Helpers/OAWikiImageHelper.mm
Outdated
{ | ||
NSString *safeWikidataTagContent = [wikidataTagContent stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; | ||
NSURL *urlObj = [[NSURL alloc] initWithString: [NSString stringWithFormat:@"%@%@%@%@", WIKIDATA_API_ENDPOINT, WIKIDATA_ACTION, safeWikidataTagContent, FORMAT_JSON]]; | ||
NSURLSession *aSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; |
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.
*session
Sources/Helpers/OAWikiImageHelper.mm
Outdated
NSString *url = [NSString stringWithFormat:@"%@%@%@%@%@", WIKIMEDIA_API_ENDPOINT, WIKIMEDIA_ACTION, wikiMediaTagContent, CM_LIMIT, FORMAT_JSON]; | ||
url = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; | ||
NSURL *urlObj = [[NSURL alloc] initWithString:url]; | ||
NSURLSession *aSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; |
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.
*session
No description provided.