diff --git a/Alcatraz/Controllers/ATZPackageTableViewDelegate.h b/Alcatraz/Controllers/ATZPackageTableViewDelegate.h index c74b02c..3699a8e 100644 --- a/Alcatraz/Controllers/ATZPackageTableViewDelegate.h +++ b/Alcatraz/Controllers/ATZPackageTableViewDelegate.h @@ -29,6 +29,8 @@ - (instancetype)initWithPackages:(NSArray*)packages tableViewOwner:(id)owner; +- (void)updatePackages:(NSArray*)packages; + - (void)configureTableView:(NSTableView*)tableView; - (void)filterUsingPredicate:(NSPredicate*)predicate; diff --git a/Alcatraz/Controllers/ATZPackageTableViewDelegate.m b/Alcatraz/Controllers/ATZPackageTableViewDelegate.m index 05436bd..b840301 100644 --- a/Alcatraz/Controllers/ATZPackageTableViewDelegate.m +++ b/Alcatraz/Controllers/ATZPackageTableViewDelegate.m @@ -53,6 +53,10 @@ - (instancetype)initWithPackages:(NSArray*)packages tableViewOwner:(id)owner { return self; } +- (void)updatePackages:(NSArray*)packages { + _packages = packages; +} + - (void)configureTableView:(NSTableView *)tableView { NSNib* nib = [[NSNib alloc] initWithNibNamed:NSStringFromClass([ATZPackageListTableCellView class]) bundle:[Alcatraz sharedPlugin].bundle]; [tableView registerNib:nib forIdentifier:packageCellIdentifier]; diff --git a/Alcatraz/Controllers/ATZPluginWindowController.m b/Alcatraz/Controllers/ATZPluginWindowController.m index 9ed0318..0d1c984 100644 --- a/Alcatraz/Controllers/ATZPluginWindowController.m +++ b/Alcatraz/Controllers/ATZPluginWindowController.m @@ -178,13 +178,19 @@ - (IBAction)resetPackageRepoPath:(id)sender { } - (void)reloadTableView { - self.tableViewDelegate = [[ATZPackageTableViewDelegate alloc] initWithPackages:self.packages - tableViewOwner:self]; - self.tableView.delegate = self.tableViewDelegate; - self.tableView.dataSource = self.tableViewDelegate; - [self.tableViewDelegate configureTableView:self.tableView]; + if (!self.tableViewDelegate) { + self.tableViewDelegate = [[ATZPackageTableViewDelegate alloc] initWithPackages:self.packages + tableViewOwner:self]; + self.tableView.delegate = self.tableViewDelegate; + self.tableView.dataSource = self.tableViewDelegate; + + [self.tableViewDelegate configureTableView:self.tableView]; + } + else { + [self.tableViewDelegate updatePackages:self.packages]; + } + [self updatePredicate]; - [self.tableView reloadData]; } #pragma mark - Private