diff options
author | Vitaly Takmazov | 2018-10-21 17:03:16 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-10-21 17:03:16 +0300 |
commit | 4429035e2530f8362759d1933bbbdbf9c7d3a8a1 (patch) | |
tree | 4f78fc0bc9124f62342fbe8a9ce662ffa059a708 | |
parent | 9137ade75773e004563c1057d80d90e89d5e4ccd (diff) |
Refresh chats on swipe
-rw-r--r-- | Juick/ViewControllers/DialogsViewController.h | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/DialogsViewController.m | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Juick/ViewControllers/DialogsViewController.h b/Juick/ViewControllers/DialogsViewController.h index c37f6a6..f31830e 100644 --- a/Juick/ViewControllers/DialogsViewController.h +++ b/Juick/ViewControllers/DialogsViewController.h @@ -11,5 +11,6 @@ @interface DialogsViewController : UITableViewController @property(nonatomic, strong) NSMutableArray *chats; +-(void) refreshData; @end diff --git a/Juick/ViewControllers/DialogsViewController.m b/Juick/ViewControllers/DialogsViewController.m index d080176..e801627 100644 --- a/Juick/ViewControllers/DialogsViewController.m +++ b/Juick/ViewControllers/DialogsViewController.m @@ -20,7 +20,14 @@ self.navigationController.visibleViewController.navigationItem.title = @"Chats"; [self.view setBackgroundColor:[ColorScheme mainBackground]]; [self.tableView registerNib:[UINib nibWithNibName:@"ConversationCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"notificationCell"]; + [self refreshData]; + self.refreshControl = [UIRefreshControl new]; + [self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged]; +} + +- (void) refreshData { self.chats = [NSMutableArray array]; + [self.tableView reloadData]; [[APIClient sharedClient] fetchChats:^(NSArray *groups, NSError *err) { if (err == nil) { [self.chats addObjectsFromArray:groups]; @@ -31,6 +38,7 @@ [self.tableView beginUpdates]; [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES]; [self.tableView endUpdates]; + [self.refreshControl endRefreshing]; } }]; } |