Просмотр исходного кода

Fix bug in FLEXNetworkHistoryTableViewController

Tanner Bennett лет назад: 6
Родитель
Сommit
fa9eec08c1

+ 8 - 3
Classes/Network/FLEXNetworkHistoryTableViewController.m

@@ -60,7 +60,10 @@
 
     self.showsSearchBar = YES;
 
-    [self.tableView registerClass:[FLEXNetworkTransactionTableViewCell class] forCellReuseIdentifier:kFLEXNetworkTransactionCellIdentifier];
+    [self.tableView
+        registerClass:[FLEXNetworkTransactionTableViewCell class]
+        forCellReuseIdentifier:kFLEXNetworkTransactionCellIdentifier
+    ];
     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
     self.tableView.rowHeight = [FLEXNetworkTransactionTableViewCell preferredCellHeight];
 
@@ -137,7 +140,7 @@
 - (NSString *)headerText
 {
     NSString *headerText = nil;
-    if ([FLEXNetworkObserver isEnabled]) {
+    if (FLEXNetworkObserver.isEnabled) {
         long long bytesReceived = 0;
         NSInteger totalRequests = 0;
         if (self.searchController.isActive) {
@@ -170,7 +173,9 @@
 
 - (void)handleNewTransactionRecordedNotification:(NSNotification *)notification
 {
-    [self tryUpdateTransactions];
+    if (self.viewIfLoaded.window) {
+        [self tryUpdateTransactions];
+    }
 }
 
 - (void)tryUpdateTransactions

+ 1 - 1
Classes/Network/FLEXNetworkSettingsTableViewController.m

@@ -36,7 +36,7 @@
 
     NSMutableArray<UITableViewCell *> *mutableCells = [NSMutableArray array];
 
-    UITableViewCell *networkDebuggingCell = [self switchCellWithTitle:@"Network Debugging" toggleAction:@selector(networkDebuggingToggled:) isOn:[FLEXNetworkObserver isEnabled]];
+    UITableViewCell *networkDebuggingCell = [self switchCellWithTitle:@"Network Debugging" toggleAction:@selector(networkDebuggingToggled:) isOn:FLEXNetworkObserver.isEnabled];
     [mutableCells addObject:networkDebuggingCell];
 
     UITableViewCell *cacheMediaResponsesCell = [self switchCellWithTitle:@"Cache Media Responses" toggleAction:@selector(cacheMediaResponsesToggled:) isOn:NO];

+ 4 - 4
Classes/Network/PonyDebugger/FLEXNetworkObserver.m

@@ -323,7 +323,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
         typedef void (^NSURLConnectionAsyncCompletion)(NSURLResponse* response, NSData* data, NSError* connectionError);
 
         void (^asyncSwizzleBlock)(Class, NSURLRequest *, NSOperationQueue *, NSURLConnectionAsyncCompletion) = ^(Class slf, NSURLRequest *request, NSOperationQueue *queue, NSURLConnectionAsyncCompletion completion) {
-            if ([FLEXNetworkObserver isEnabled]) {
+            if (FLEXNetworkObserver.isEnabled) {
                 NSString *requestID = [self nextRequestID];
                 [[FLEXNetworkRecorder defaultRecorder] recordRequestWillBeSentWithRequestID:requestID request:request redirectResponse:nil];
                 NSString *mechanism = [self mechanismFromClassMethod:selector onClass:class];
@@ -362,7 +362,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
 
         NSData *(^syncSwizzleBlock)(Class, NSURLRequest *, NSURLResponse **, NSError **) = ^NSData *(Class slf, NSURLRequest *request, NSURLResponse **response, NSError **error) {
             NSData *data = nil;
-            if ([FLEXNetworkObserver isEnabled]) {
+            if (FLEXNetworkObserver.isEnabled) {
                 NSString *requestID = [self nextRequestID];
                 [[FLEXNetworkRecorder defaultRecorder] recordRequestWillBeSentWithRequestID:requestID request:request redirectResponse:nil];
                 NSString *mechanism = [self mechanismFromClassMethod:selector onClass:class];
@@ -426,7 +426,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
                 // If completion block was not provided sender expect to receive delegated methods or does not
                 // interested in callback at all. In this case we should just call original method implementation
                 // with nil completion block.
-                if ([FLEXNetworkObserver isEnabled] && completion) {
+                if (FLEXNetworkObserver.isEnabled && completion) {
                     NSString *requestID = [self nextRequestID];
                     NSString *mechanism = [self mechanismFromClassMethod:selector onClass:class];
                     NSURLSessionAsyncCompletion completionWrapper = [self asyncCompletionWrapperForRequestID:requestID mechanism:mechanism completion:completion];
@@ -470,7 +470,7 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id <NSU
 
             NSURLSessionUploadTask *(^asyncUploadTaskSwizzleBlock)(Class, NSURLRequest *, id, NSURLSessionAsyncCompletion) = ^NSURLSessionUploadTask *(Class slf, NSURLRequest *request, id argument, NSURLSessionAsyncCompletion completion) {
                 NSURLSessionUploadTask *task = nil;
-                if ([FLEXNetworkObserver isEnabled] && completion) {
+                if (FLEXNetworkObserver.isEnabled && completion) {
                     NSString *requestID = [self nextRequestID];
                     NSString *mechanism = [self mechanismFromClassMethod:selector onClass:class];
                     NSURLSessionAsyncCompletion completionWrapper = [self asyncCompletionWrapperForRequestID:requestID mechanism:mechanism completion:completion];