summaryrefslogtreecommitdiff
path: root/Juick/MessagesViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/MessagesViewController.m')
-rw-r--r--Juick/MessagesViewController.m35
1 files changed, 9 insertions, 26 deletions
diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m
index 6930de8..e8e02e1 100644
--- a/Juick/MessagesViewController.m
+++ b/Juick/MessagesViewController.m
@@ -27,7 +27,6 @@ static NSString *CellIdentifier = @"MessageCell";
@property(nonatomic, assign) Boolean dataLoading;
@property(nonatomic, strong) NSString *path;
@property(nonatomic, strong) NSMutableDictionary *params;
-@property(nonatomic, strong) MessageCell *sizingCell;
@end
@@ -36,7 +35,7 @@ static NSString *CellIdentifier = @"MessageCell";
- (void)loadFromPath:(NSString *)messagesPath withParams:(NSDictionary *)params withTitle:(NSString *)title
{
[self setPath:messagesPath];
- [self setParams:params];
+ [self setParams:[[NSMutableDictionary alloc] initWithDictionary:params]];
self.title = title;
[self refreshData:nil];
}
@@ -47,12 +46,11 @@ static NSString *CellIdentifier = @"MessageCell";
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
self.dataLoading = YES;
[Message pullNextFromPath:self.path params:self.params callback:^(NSArray *next) {
- dispatch_async(dispatch_get_main_queue(), ^{
[self.messages addObjectsFromArray:next];
[self.tableView reloadData];
[refresh endRefreshing];
self.dataLoading = NO;
- });
+
}];
});
}
@@ -80,11 +78,10 @@ static NSString *CellIdentifier = @"MessageCell";
[self.params setObject:lastMessage.MID forKey:@"before_mid"];
}
[Message pullNextFromPath:self.path params:self.params callback:^(NSArray *next) {
- dispatch_async(dispatch_get_main_queue(), ^{
[self.messages addObjectsFromArray:next];
[self.tableView reloadData];
self.dataLoading = NO;
- });
+
}];
});
@@ -109,12 +106,7 @@ static NSString *CellIdentifier = @"MessageCell";
self.navigationController.navigationBar.tintColor = [ColorScheme navbarBackground];
}
- [self.tableView registerClass:[MessageCell class] forCellReuseIdentifier:CellIdentifier];
- self.sizingCell = [[MessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
- self.sizingCell.hidden = YES;
- [self.tableView addSubview:self.sizingCell];
-
- self.sizingCell.frame = CGRectMake(0, 0, CGRectGetWidth(self.tableView.bounds), 0);
+ [self.tableView registerClass:[MessageCell class] forCellReuseIdentifier:CellIdentifier];
}
- (void) composePressed {
@@ -171,26 +163,17 @@ static NSString *CellIdentifier = @"MessageCell";
MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
[cell updateFonts];
Message *msg = [_messages objectAtIndex:indexPath.row];
- [cell bind:msg];
-
- [cell.contentView layoutIfNeeded];
+ [cell setMessage:msg];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
- [self.sizingCell updateFonts];
-
+ MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ [cell updateFonts];
Message *msg = [_messages objectAtIndex:indexPath.row];
-
- [self.sizingCell bind:msg];
-
- [self.sizingCell setNeedsLayout];
- [self.sizingCell layoutIfNeeded];
-
- CGFloat calculatedHeight = [self.sizingCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
-
- return calculatedHeight;
+ [cell setMessage:msg];
+ return [cell heightForCell];
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath