Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Addressed PR feedback. Calls delegate method on main queue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Rex committed Jul 15, 2019
1 parent 4250e08 commit 228e402
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions platform/darwin/src/MGLNetworkConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ - (NSURLSessionConfiguration *)defaultSessionConfiguration {
}

- (void)startDownloadEvent:(NSString *)urlString type:(NSString *)resourceType {
NSDate *startDate = [NSDate date];
if (urlString && ![self eventDictionaryForKey:urlString]) {
NSDate *startDate = [NSDate date];
[self setEventDictionary:@{ MGLStartTime: startDate, MGLResourceType: resourceType } forKey:urlString];
}
}
Expand All @@ -87,8 +87,11 @@ - (void)sendEventForURLResponse:(NSURLResponse *)response withAction:(NSString *
NSString *urlString = response.URL.relativePath;
if (urlString && [self eventDictionaryForKey:urlString]) {
NSDictionary *eventAttributes = [self eventAttributesForURL:response withAction:action];
[self.metricsDelegate networkConfiguration:self didGenerateMetricEvent:eventAttributes];
[self removeEventDictionaryForKey:urlString];

dispatch_async(dispatch_get_main_queue(), ^{
[self.metricsDelegate networkConfiguration:self didGenerateMetricEvent:eventAttributes];
});
}
}

Expand Down
1 change: 1 addition & 0 deletions platform/ios/test/MGLNetworkConfigurationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ @interface MGLNetworkConfigurationTests : XCTestCase

@implementation MGLNetworkConfigurationTests

// Regression test for https://github.com/mapbox/mapbox-gl-native/issues/14982
- (void)testAccessingEventsFromMultipleThreads {
MGLNetworkConfiguration *configuration = [[MGLNetworkConfiguration alloc] init];

Expand Down

0 comments on commit 228e402

Please sign in to comment.