-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathFLEXNetworkMITMViewController.m
More file actions
636 lines (524 loc) · 24.4 KB
/
Copy pathFLEXNetworkMITMViewController.m
File metadata and controls
636 lines (524 loc) · 24.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
//
// FLEXNetworkMITMViewController.m
// Flipboard
//
// Created by Ryan Olson on 2/8/15.
// Copyright (c) 2020 FLEX Team. All rights reserved.
//
#import "FLEXColor.h"
#import "FLEXUtility.h"
#import "FLEXMITMDataSource.h"
#import "FLEXNetworkMITMViewController.h"
#import "FLEXNetworkTransaction.h"
#import "FLEXNetworkRecorder.h"
#import "FLEXNetworkObserver.h"
#import "FLEXNetworkTransactionCell.h"
#import "FLEXHTTPTransactionDetailController.h"
#import "FLEXNetworkSettingsController.h"
#import "FLEXObjectExplorerFactory.h"
#import "FLEXGlobalsViewController.h"
#import "FLEXWebViewController.h"
#import "UIBarButtonItem+FLEX.h"
#import "FLEXResources.h"
#import "NSUserDefaults+FLEX.h"
#define kFirebaseAvailable NSClassFromString(@"FIRDocumentReference")
#define kWebsocketsAvailable @available(iOS 13.0, *)
typedef NS_ENUM(NSInteger, FLEXNetworkObserverMode) {
FLEXNetworkObserverModeFirebase = 0,
FLEXNetworkObserverModeREST,
FLEXNetworkObserverModeWebsockets,
};
@interface FLEXNetworkMITMViewController ()
@property (nonatomic) BOOL updateInProgress;
@property (nonatomic) BOOL pendingReload;
@property (nonatomic) FLEXNetworkObserverMode mode;
@property (nonatomic, readonly) FLEXMITMDataSource<FLEXNetworkTransaction *> *dataSource;
@property (nonatomic, readonly) FLEXMITMDataSource<FLEXHTTPTransaction *> *HTTPDataSource;
@property (nonatomic, readonly) FLEXMITMDataSource<FLEXWebsocketTransaction *> *websocketDataSource;
@property (nonatomic, readonly) FLEXMITMDataSource<FLEXFirebaseTransaction *> *firebaseDataSource;
@end
@implementation FLEXNetworkMITMViewController
#pragma mark - Lifecycle
- (id)init {
return [self initWithStyle:UITableViewStylePlain];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.showsSearchBar = YES;
self.pinSearchBar = YES;
self.showSearchBarInitially = NO;
NSMutableArray *scopeTitles = [NSMutableArray arrayWithObject:@"REST"];
_HTTPDataSource = [FLEXMITMDataSource dataSourceWithProvider:^NSArray * {
return FLEXNetworkRecorder.defaultRecorder.HTTPTransactions;
}];
if (kFirebaseAvailable) {
_firebaseDataSource = [FLEXMITMDataSource dataSourceWithProvider:^NSArray * {
return FLEXNetworkRecorder.defaultRecorder.firebaseTransactions;
}];
[scopeTitles insertObject:@"Firebase" atIndex:0]; // First space
}
if (kWebsocketsAvailable) {
[scopeTitles addObject:@"Websockets"]; // Last space
_websocketDataSource = [FLEXMITMDataSource dataSourceWithProvider:^NSArray * {
return FLEXNetworkRecorder.defaultRecorder.websocketTransactions;
}];
}
// Scopes will only be shown if we have either firebase or websockets available
self.searchController.searchBar.showsScopeBar = scopeTitles.count > 1;
self.searchController.searchBar.scopeButtonTitles = scopeTitles;
self.mode = NSUserDefaults.standardUserDefaults.flex_lastNetworkObserverMode;
[self addToolbarItems:@[
[UIBarButtonItem
flex_itemWithImage:FLEXResources.gearIcon
target:self
action:@selector(settingsButtonTapped:)
],
[[UIBarButtonItem
flex_systemItem:UIBarButtonSystemItemTrash
target:self
action:@selector(trashButtonTapped:)
] flex_withTintColor:UIColor.redColor]
]];
[self.tableView
registerClass:FLEXNetworkTransactionCell.class
forCellReuseIdentifier:FLEXNetworkTransactionCell.reuseID
];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.rowHeight = FLEXNetworkTransactionCell.preferredCellHeight;
[self registerForNotifications];
[self updateTransactions:nil];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Reload the table if we received updates while not on-screen
if (self.pendingReload) {
[self.tableView reloadData];
self.pendingReload = NO;
}
}
- (void)dealloc {
[NSNotificationCenter.defaultCenter removeObserver:self];
}
- (void)registerForNotifications {
NSDictionary *notifications = @{
kFLEXNetworkRecorderNewTransactionNotification:
NSStringFromSelector(@selector(handleNewTransactionRecordedNotification:)),
kFLEXNetworkRecorderTransactionUpdatedNotification:
NSStringFromSelector(@selector(handleTransactionUpdatedNotification:)),
kFLEXNetworkRecorderTransactionsClearedNotification:
NSStringFromSelector(@selector(handleTransactionsClearedNotification:)),
kFLEXNetworkObserverEnabledStateChangedNotification:
NSStringFromSelector(@selector(handleNetworkObserverEnabledStateChangedNotification:)),
};
for (NSString *name in notifications.allKeys) {
[NSNotificationCenter.defaultCenter addObserver:self
selector:NSSelectorFromString(notifications[name]) name:name object:nil
];
}
}
#pragma mark - Private
#pragma mark Button Actions
- (void)settingsButtonTapped:(UIBarButtonItem *)sender {
UIViewController *settings = [FLEXNetworkSettingsController new];
settings.navigationItem.rightBarButtonItem = FLEXBarButtonItemSystem(
Done, self, @selector(settingsViewControllerDoneTapped:)
);
settings.title = @"Network Debugging Settings";
// This is not a FLEXNavigationController because it is not intended as a new tab
UIViewController *nav = [[UINavigationController alloc] initWithRootViewController:settings];
[self presentViewController:nav animated:YES completion:nil];
}
- (void)trashButtonTapped:(UIBarButtonItem *)sender {
[FLEXAlert makeSheet:^(FLEXAlert *make) {
BOOL clearAll = !self.dataSource.isFiltered;
if (!clearAll) {
make.title(@"Clear Filtered Requests?");
make.message(@"This will only remove the requests matching your search string on this screen.");
} else {
make.title(@"Clear All Recorded Requests?");
make.message(@"This cannot be undone.");
}
make.button(@"Cancel").cancelStyle();
make.button(@"Clear").destructiveStyle().handler(^(NSArray *strings) {
if (clearAll) {
[FLEXNetworkRecorder.defaultRecorder clearRecordedActivity];
} else {
FLEXNetworkTransactionKind kind = (FLEXNetworkTransactionKind)self.mode;
[FLEXNetworkRecorder.defaultRecorder clearRecordedActivity:kind matching:self.searchText];
}
});
} showFrom:self source:sender];
}
- (void)settingsViewControllerDoneTapped:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark Transactions
- (FLEXNetworkObserverMode)mode {
FLEXNetworkObserverMode mode = self.searchController.searchBar.selectedScopeButtonIndex;
switch (mode) {
case FLEXNetworkObserverModeFirebase:
if (kFirebaseAvailable) {
return FLEXNetworkObserverModeFirebase;
}
return FLEXNetworkObserverModeREST;
case FLEXNetworkObserverModeREST:
if (kFirebaseAvailable) {
return FLEXNetworkObserverModeREST;
}
return FLEXNetworkObserverModeWebsockets;
case FLEXNetworkObserverModeWebsockets:
return FLEXNetworkObserverModeWebsockets;
}
}
- (void)setMode:(FLEXNetworkObserverMode)mode {
// The segmentd control will have different appearances based on which APIs
// are available. For example, when only Websockets is available:
//
// 0 1
// ┌───────────────────────────┬────────────────────────────┐
// │ REST │ Websockets │
// └───────────────────────────┴────────────────────────────┘
//
// And when both Firebase and Websockets are available:
//
// 0 1 2
// ┌──────────────────┬──────────────────┬──────────────────┐
// │ Firebase │ REST │ Websockets │
// └──────────────────┴──────────────────┴──────────────────┘
//
// As a result, we need to adjust the input mode variable accordingly
// before we actually set it. When we try to set it to Firebase but
// Firebase is not available, we don't do anything, because when Firebase
// is unavailable, FLEXNetworkObserverModeFirebase represents the same index
// as REST would without Firebase. For each of the others, we subtract 1
// from them for every relevant API that is unavailable. So for Websockets,
// if it is unavailable, we subtract 1 and it becomes FLEXNetworkObserverModeREST.
// And if Firebase is also unavailable, we subtract 1 again.
switch (mode) {
case FLEXNetworkObserverModeFirebase:
// Will default to REST if Firebase is unavailable
break;
case FLEXNetworkObserverModeREST:
// Firebase will become REST when Firebase is unavailable
if (!kFirebaseAvailable) {
mode--;
}
break;
case FLEXNetworkObserverModeWebsockets:
// Default to REST if Websockets are unavailable
if (!kWebsocketsAvailable) {
mode--;
}
// Firebase will become REST when Firebase is unavailable
if (!kFirebaseAvailable) {
mode--;
}
}
self.searchController.searchBar.selectedScopeButtonIndex = mode;
}
- (FLEXMITMDataSource<FLEXNetworkTransaction *> *)dataSource {
switch (self.mode) {
case FLEXNetworkObserverModeREST:
return self.HTTPDataSource;
case FLEXNetworkObserverModeWebsockets:
return self.websocketDataSource;
case FLEXNetworkObserverModeFirebase:
return self.firebaseDataSource;
}
}
- (void)updateTransactions:(void(^)(void))callback {
id completion = ^(FLEXMITMDataSource *dataSource) {
// Update byte count
[self updateFirstSectionHeader];
if (callback && dataSource == self.dataSource) callback();
};
[self.HTTPDataSource reloadData:completion];
[self.websocketDataSource reloadData:completion];
[self.firebaseDataSource reloadData:completion];
}
#pragma mark Header
- (void)updateFirstSectionHeader {
UIView *view = [self.tableView headerViewForSection:0];
if ([view isKindOfClass:[UITableViewHeaderFooterView class]]) {
UITableViewHeaderFooterView *headerView = (UITableViewHeaderFooterView *)view;
headerView.textLabel.text = [self headerText];
[headerView setNeedsLayout];
}
}
- (NSString *)headerText {
long long bytesReceived = self.dataSource.bytesReceived;
NSInteger totalRequests = self.dataSource.transactions.count;
NSString *byteCountText = [NSByteCountFormatter
stringFromByteCount:bytesReceived countStyle:NSByteCountFormatterCountStyleBinary
];
NSString *requestsText = totalRequests == 1 ? @"Request" : @"Requests";
// Exclude byte count from Firebase
if (self.mode == FLEXNetworkObserverModeFirebase) {
return [NSString stringWithFormat:@"%@ %@",
@(totalRequests), requestsText
];
}
return [NSString stringWithFormat:@"%@ %@ (%@ received)",
@(totalRequests), requestsText, byteCountText
];
}
#pragma mark - FLEXGlobalsEntry
+ (NSString *)globalsEntryTitle:(FLEXGlobalsRow)row {
return @"📡 Network History";
}
+ (FLEXGlobalsEntryRowAction)globalsEntryRowAction:(FLEXGlobalsRow)row {
return ^(UITableViewController *host) {
if (FLEXNetworkObserver.isEnabled) {
[host.navigationController pushViewController:[
self globalsEntryViewController:row
] animated:YES];
} else {
[FLEXAlert makeAlert:^(FLEXAlert *make) {
make.title(@"Network Monitor Disabled");
make.message(@"You must enable network monitoring to proceed.");
make.button(@"Turn On").preferred().handler(^(NSArray<NSString *> *strings) {
FLEXNetworkObserver.enabled = YES;
[host.navigationController pushViewController:[
self globalsEntryViewController:row
] animated:YES];
});
make.button(@"Dismiss").cancelStyle();
} showFrom:host];
}
};
}
+ (UIViewController *)globalsEntryViewController:(FLEXGlobalsRow)row {
UIViewController *controller = [self new];
controller.title = [self globalsEntryTitle:row];
return controller;
}
#pragma mark - Notification Handlers
- (void)handleNewTransactionRecordedNotification:(NSNotification *)notification {
[self tryUpdateTransactions];
}
- (void)tryUpdateTransactions {
// Don't do any view updating if we aren't in the view hierarchy
if (!self.viewIfLoaded.window) {
[self updateTransactions:nil];
self.pendingReload = YES;
return;
}
// Let the previous row insert animation finish before starting a new one to avoid stomping.
// We'll try calling the method again when the insertion completes,
// and we properly no-op if there haven't been changes.
if (self.updateInProgress) {
return;
}
self.updateInProgress = YES;
// Get state before update
NSString *currentFilter = self.searchText;
FLEXNetworkObserverMode currentMode = self.mode;
NSInteger existingRowCount = self.dataSource.transactions.count;
[self updateTransactions:^{
// Compare to state after update
NSString *newFilter = self.searchText;
FLEXNetworkObserverMode newMode = self.mode;
NSInteger newRowCount = self.dataSource.transactions.count;
NSInteger rowCountDiff = newRowCount - existingRowCount;
// Abort if the observation mode changed, or if the search field text changed
if (newMode != currentMode || ![currentFilter isEqualToString:newFilter]) {
self.updateInProgress = NO;
return;
}
if (rowCountDiff) {
// Insert animation if we're at the top.
if (self.tableView.contentOffset.y <= 0.0 && rowCountDiff > 0) {
[CATransaction begin];
[CATransaction setCompletionBlock:^{
self.updateInProgress = NO;
// This isn't an infinite loop, it won't run a third time
// if there were no new transactions the second time
[self tryUpdateTransactions];
}];
NSMutableArray<NSIndexPath *> *indexPathsToReload = [NSMutableArray new];
for (NSInteger row = 0; row < rowCountDiff; row++) {
[indexPathsToReload addObject:[NSIndexPath indexPathForRow:row inSection:0]];
}
[self.tableView insertRowsAtIndexPaths:indexPathsToReload withRowAnimation:UITableViewRowAnimationAutomatic];
[CATransaction commit];
} else {
// Maintain the user's position if they've scrolled down.
CGSize existingContentSize = self.tableView.contentSize;
[self.tableView reloadData];
CGFloat contentHeightChange = self.tableView.contentSize.height - existingContentSize.height;
self.tableView.contentOffset = CGPointMake(self.tableView.contentOffset.x, self.tableView.contentOffset.y + contentHeightChange);
self.updateInProgress = NO;
}
} else {
self.updateInProgress = NO;
}
}];
}
- (void)handleTransactionUpdatedNotification:(NSNotification *)notification {
[self.HTTPDataSource reloadByteCounts];
[self.websocketDataSource reloadByteCounts];
// Don't need to reload Firebase here
FLEXNetworkTransaction *transaction = notification.userInfo[kFLEXNetworkRecorderUserInfoTransactionKey];
// Update both the main table view and search table view if needed.
for (FLEXNetworkTransactionCell *cell in self.tableView.visibleCells) {
if ([cell.transaction isEqual:transaction]) {
// Using -[UITableView reloadRowsAtIndexPaths:withRowAnimation:] is overkill here and kicks off a lot of
// work that can make the table view somewhat unresponsive when lots of updates are streaming in.
// We just need to tell the cell that it needs to re-layout.
[cell setNeedsLayout];
break;
}
}
[self updateFirstSectionHeader];
}
- (void)handleTransactionsClearedNotification:(NSNotification *)notification {
[self updateTransactions:^{
[self.tableView reloadData];
}];
}
- (void)handleNetworkObserverEnabledStateChangedNotification:(NSNotification *)notification {
// Update the header, which displays a warning when network debugging is disabled
[self updateFirstSectionHeader];
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataSource.transactions.count;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return [self headerText];
}
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
if ([view isKindOfClass:[UITableViewHeaderFooterView class]]) {
UITableViewHeaderFooterView *headerView = (UITableViewHeaderFooterView *)view;
headerView.textLabel.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightSemibold];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
FLEXNetworkTransactionCell *cell = [tableView
dequeueReusableCellWithIdentifier:FLEXNetworkTransactionCell.reuseID
forIndexPath:indexPath
];
cell.transaction = [self transactionAtIndexPath:indexPath];
// Since we insert from the top, assign background colors bottom up to keep them consistent for each transaction.
NSInteger totalRows = [tableView numberOfRowsInSection:indexPath.section];
if ((totalRows - indexPath.row) % 2 == 0) {
cell.backgroundColor = FLEXColor.secondaryBackgroundColor;
} else {
cell.backgroundColor = FLEXColor.primaryBackgroundColor;
}
// Add accessibility identifier for automated testing
cell.accessibilityIdentifier = [NSString stringWithFormat:@"network_call_%ld", (long)indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch (self.mode) {
case FLEXNetworkObserverModeREST: {
FLEXHTTPTransaction *transaction = [self HTTPTransactionAtIndexPath:indexPath];
UIViewController *details = [FLEXHTTPTransactionDetailController withTransaction:transaction];
[self.navigationController pushViewController:details animated:YES];
break;
}
case FLEXNetworkObserverModeWebsockets: {
if (@available(iOS 13.0, *)) { // This check will never fail
FLEXWebsocketTransaction *transaction = [self websocketTransactionAtIndexPath:indexPath];
UIViewController *details = nil;
if (transaction.message.type == NSURLSessionWebSocketMessageTypeData) {
details = [FLEXObjectExplorerFactory explorerViewControllerForObject:transaction.message.data];
} else {
details = [[FLEXWebViewController alloc] initWithText:transaction.message.string];
}
[self.navigationController pushViewController:details animated:YES];
}
break;
}
case FLEXNetworkObserverModeFirebase: {
FLEXFirebaseTransaction *transaction = [self firebaseTransactionAtIndexPath:indexPath];
// id obj = transaction.documents.count == 1 ? transaction.documents.firstObject : transaction.documents;
UIViewController *explorer = [FLEXObjectExplorerFactory explorerViewControllerForObject:transaction];
[self.navigationController pushViewController:explorer animated:YES];
}
}
}
#pragma mark - Menu Actions
- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
return action == @selector(copy:);
}
- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
if (action == @selector(copy:)) {
UIPasteboard.generalPasteboard.string = [self transactionAtIndexPath:indexPath].copyString;
}
}
- (UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath point:(CGPoint)point __IOS_AVAILABLE(13.0) {
FLEXNetworkTransaction *transaction = [self transactionAtIndexPath:indexPath];
return [UIContextMenuConfiguration
configurationWithIdentifier:nil
previewProvider:nil
actionProvider:^UIMenu *(NSArray<UIMenuElement *> *suggestedActions) {
UIAction *copy = [UIAction
actionWithTitle:@"Copy URL"
image:nil
identifier:nil
handler:^(__kindof UIAction *action) {
UIPasteboard.generalPasteboard.string = transaction.copyString;
}
];
NSArray *children = @[copy];
if (self.mode == FLEXNetworkObserverModeREST) {
NSURLRequest *request = [self HTTPTransactionAtIndexPath:indexPath].request;
UIAction *denylist = [UIAction
actionWithTitle:[NSString stringWithFormat:@"Exclude '%@'", request.URL.host]
image:nil
identifier:nil
handler:^(__kindof UIAction *action) {
NSMutableArray *denylist = FLEXNetworkRecorder.defaultRecorder.hostDenylist;
[denylist addObject:request.URL.host];
[FLEXNetworkRecorder.defaultRecorder clearExcludedTransactions];
[FLEXNetworkRecorder.defaultRecorder synchronizeDenylist];
[self tryUpdateTransactions];
}
];
children = [children arrayByAddingObject:denylist];
}
return [UIMenu
menuWithTitle:@"" image:nil identifier:nil
options:UIMenuOptionsDisplayInline
children:children
];
}
];
}
- (FLEXNetworkTransaction *)transactionAtIndexPath:(NSIndexPath *)indexPath {
return self.dataSource.transactions[indexPath.row];
}
- (FLEXHTTPTransaction *)HTTPTransactionAtIndexPath:(NSIndexPath *)indexPath {
return self.HTTPDataSource.transactions[indexPath.row];
}
- (FLEXWebsocketTransaction *)websocketTransactionAtIndexPath:(NSIndexPath *)indexPath {
return self.websocketDataSource.transactions[indexPath.row];
}
- (FLEXFirebaseTransaction *)firebaseTransactionAtIndexPath:(NSIndexPath *)indexPath {
return self.firebaseDataSource.transactions[indexPath.row];
}
#pragma mark - Search Bar
- (void)updateSearchResults:(NSString *)searchString {
id callback = ^(FLEXMITMDataSource *dataSource) {
if (self.dataSource == dataSource) {
[self.tableView reloadData];
}
};
[self.HTTPDataSource filter:searchString completion:callback];
[self.websocketDataSource filter:searchString completion:callback];
[self.firebaseDataSource filter:searchString completion:callback];
}
- (void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)newScope {
[self updateFirstSectionHeader];
[self.tableView reloadData];
NSUserDefaults.standardUserDefaults.flex_lastNetworkObserverMode = self.mode;
}
- (void)willDismissSearchController:(UISearchController *)searchController {
[self.tableView reloadData];
}
@end