summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/ViewControllers/MessagesViewController.m14
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;