diff options
author | Vitaly Takmazov | 2017-10-16 19:02:41 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-16 19:02:41 +0300 |
commit | 07afcd6f36629f30a495f2be47262c75c006712f (patch) | |
tree | 2ac89146ec9eb3a1caaf62228e9546e130450cba /Juick | |
parent | 8ae952ec8df2a713afeaef5960a88888e050c6fc (diff) |
begin updates
Diffstat (limited to 'Juick')
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.m | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index badc4a3..e4d0e1c 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -32,10 +32,10 @@ self.dataLoading = YES; [[APIClient sharedClient] pullNextFromPath:self.path params:self.params callback:^(NSArray *next, NSError *err) { NSArray *newMsgs = next; + NSUInteger oldCount = [self.messages count]; if ([self.path isEqualToString:[APIClient threadUrl]]) { NSUInteger lastRid = [((Message *)[self.messages lastObject]).rid unsignedIntegerValue]; NSUInteger count = [next count] - 1; - NSUInteger oldCount = [self.messages count]; if (oldCount > 0) { if (lastRid && lastRid < count) { newMsgs = [next subarrayWithRange:NSMakeRange(lastRid, count - lastRid)]; @@ -45,7 +45,13 @@ } } [self.messages addObjectsFromArray:newMsgs]; - [self.tableView reloadData]; + NSMutableArray *indexPaths = [NSMutableArray new]; + for (NSUInteger index = oldCount; index <= oldCount + [newMsgs count] - 1; index++) { + [indexPaths addObject:[NSIndexPath indexPathForRow:index inSection: 0]]; + } + [self.tableView beginUpdates]; + [self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:YES]; + [self.tableView endUpdates]; [self.refreshControl endRefreshing]; self.dataLoading = NO; }]; @@ -114,10 +120,10 @@ [self.navigationController pushViewController:threadViewController animated:NO]; } --(void)scrollViewDidScroll:(UIScrollView *)scrollView_ { +-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView_ { CGFloat actualPosition = scrollView_.contentOffset.y; CGFloat contentHeight = scrollView_.contentSize.height - scrollView_.contentSize.height / 2; - if (actualPosition >= contentHeight && !self.dataLoading) { + if (actualPosition >= contentHeight && !self.dataLoading && ![self.tableView isTracking]) { Message *lastMsg = [self.messages lastObject]; if (lastMsg != nil) { NSNumber *lastMid = lastMsg.mid; |