From 4429035e2530f8362759d1933bbbdbf9c7d3a8a1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 21 Oct 2018 17:03:16 +0300 Subject: Refresh chats on swipe --- Juick/ViewControllers/DialogsViewController.m | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Juick/ViewControllers/DialogsViewController.m') 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]; } }]; } -- cgit v1.2.3