diff options
Diffstat (limited to 'Juick/MessagesViewController.m')
-rw-r--r-- | Juick/MessagesViewController.m | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m index 7369bd9..4beeb1c 100644 --- a/Juick/MessagesViewController.m +++ b/Juick/MessagesViewController.m @@ -18,7 +18,6 @@ #import "NSURL+PathParameters.h" -#import <SDWebImage/UIImageView+WebCache.h> static NSString *CellIdentifier = @"MessageCell"; @@ -43,14 +42,8 @@ static NSString *CellIdentifier = @"MessageCell"; [self.messages removeAllObjects]; [self.tableView reloadData]; [Message pullNextFromURL:self.url callback:^(NSArray *next) { - [self.tableView beginUpdates]; - CGPoint offset = self.tableView.contentOffset; - for (int i = 0; i < [next count]; i++) { - [self.messages addObject:[next objectAtIndex:i]]; - [self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:self.messages.count-1 inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; - } - [self.tableView setContentOffset:offset animated:NO]; - [self.tableView endUpdates]; + [self.messages addObjectsFromArray:next]; + [self.tableView reloadData]; [refresh endRefreshing]; }]; } @@ -61,7 +54,7 @@ static NSString *CellIdentifier = @"MessageCell"; } - (void)scrollViewDidScroll:(UIScrollView *)scrollView { - if (self.url.absoluteString == [Message threadUrl]) { + if ([self.url.absoluteString hasPrefix:[Message threadUrl]]) { return; } CGPoint pos = scrollView.contentOffset; @@ -72,14 +65,11 @@ static NSString *CellIdentifier = @"MessageCell"; Message * lastMessage = [self.messages lastObject]; NSURL *beforeUrl = [self.url URLByAppendingParameters:[NSDictionary dictionaryWithObjectsAndKeys:lastMessage.MID, @"before_mid", nil]]; [Message pullNextFromURL:beforeUrl callback:^(NSArray *next) { - [self.tableView beginUpdates]; - for (int i = 0; i < [next count]; i++) { - [self.messages addObject:[next objectAtIndex:i]]; - [self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:self.messages.count-1 inSection:0]] withRowAnimation:UITableViewRowAnimationNone]; - } - [self.tableView setContentOffset:pos animated:NO]; - [self.tableView endUpdates]; - self.dataLoading = NO; + dispatch_async(dispatch_get_main_queue(), ^{ + [self.messages addObjectsFromArray:next]; + [self.tableView reloadData]; + self.dataLoading = NO; + }); }]; }); @@ -184,7 +174,7 @@ static NSString *CellIdentifier = @"MessageCell"; - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath { - return 100.0f; + return 500.0f; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { @@ -192,7 +182,7 @@ static NSString *CellIdentifier = @"MessageCell"; return; Message *msg = [_messages objectAtIndex:indexPath.row]; MessagesViewController *threadViewController = [[MessagesViewController alloc] init]; - [threadViewController loadFromURL:[[NSURL URLWithString:[Message threadUrl]] URLByAppendingParameters:[NSDictionary dictionaryWithObjectsAndKeys:msg.MID, @"mid", nil]] withTitle:[NSString stringWithFormat:@"#%@", msg.MID]]; + [threadViewController loadFromURL:[[NSURL URLWithString:[Message threadUrl]] URLByAppendingParameters:[NSDictionary dictionaryWithObjectsAndKeys:msg.MID, @"mid", nil]] withTitle:@"Thread"]; [self.navigationController pushViewController:threadViewController animated:NO]; } |