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

Reload the relevant network transaction cell in the history view controller when the transaction updates.

Ryan Olson лет назад: 11
Родитель
Сommit
18e2edb15f
1 измененных файлов с 16 добавлено и 0 удалено
  1. 16 0
      Classes/Network/FLEXNetworkHistoryTableViewController.m

+ 16 - 0
Classes/Network/FLEXNetworkHistoryTableViewController.m

@@ -29,6 +29,7 @@
     self = [super initWithStyle:style];
     if (self) {
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNewTransactionRecordedNotification:) name:kFLEXNetworkRecorderNewTransactionNotification object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleTransactionUpdatedNotification:) name:kFLEXNetworkRecorderTransactionUpdatedNotification object:nil];
         self.title = @"📡  Network";
     }
     return self;
@@ -76,6 +77,21 @@
     }
 }
 
+- (void)handleTransactionUpdatedNotification:(NSNotification *)notification
+{
+    FLEXNetworkTransaction *transaction = [notification.userInfo objectForKey:kFLEXNetworkRecorderUserInfoTransactionKey];
+    UITableView *activeTableView = self.searchController.isActive ? self.searchController.searchResultsTableView : self.tableView;
+    for (FLEXNetworkTransactionTableViewCell *cell in [activeTableView visibleCells]) {
+        if ([cell.transaction isEqual:transaction]) {
+            NSIndexPath *indexPath = [activeTableView indexPathForCell:cell];
+            if (indexPath) {
+                [activeTableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
+            }
+            break;
+        }
+    }
+}
+
 #pragma mark - Table view data source
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView