From 87c992e9db9464215d12a3987fe384d65e96bc50 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 22 Dec 2016 20:02:37 +0300 Subject: refactoring --- Juick/ViewControllers/MessagesViewController.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Juick/ViewControllers/MessagesViewController.m') diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index 3a420e1..e8857a7 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -48,12 +48,12 @@ 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(), ^{ + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ [self.messages addObjectsFromArray:next]; [self.tableView reloadData]; [self.refreshControl endRefreshing]; self.dataLoading = NO; - }); + }]; }]; }); } @@ -128,12 +128,12 @@ static NSString *CellIdentifier = @"MessageCell"; [cell setMessage:msg]; if ([msg.attach length] > 0) { [cell.attach yy_setImageWithURL:[NSURL URLWithString:msg.attach] placeholder:[UIImage imageNamed:@"AttachPlaceholder"] options:YYWebImageOptionProgressiveBlur | YYWebImageOptionSetImageWithFadeAnimation completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) { - dispatch_async(dispatch_get_main_queue(), ^{ + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ [cell setNeedsUpdateConstraints]; [cell updateConstraintsIfNeeded]; [cell setNeedsLayout]; [cell layoutIfNeeded]; - }); + }]; }]; } else { @@ -148,7 +148,7 @@ static NSString *CellIdentifier = @"MessageCell"; return; Message *msg = [_messages objectAtIndex:indexPath.row]; MessagesViewController *threadViewController = [[MessagesViewController alloc] init]; - [threadViewController loadFromPath:[Message threadUrl] withParams:[NSDictionary dictionaryWithObjectsAndKeys:msg.MID, @"mid", nil] withTitle:@"Thread"]; + [threadViewController loadFromPath:[Message threadUrl] withParams:[NSDictionary dictionaryWithObjectsAndKeys:msg.mid, @"mid", nil] withTitle:@"Thread"]; [self.navigationController pushViewController:threadViewController animated:NO]; } @@ -156,7 +156,7 @@ static NSString *CellIdentifier = @"MessageCell"; CGFloat actualPosition = scrollView_.contentOffset.y; CGFloat contentHeight = scrollView_.contentSize.height - scrollView_.contentSize.height / 2; if (actualPosition >= contentHeight && !self.dataLoading) { - NSNumber *lastMid = ((Message *)[self.messages lastObject]).MID; + NSNumber *lastMid = ((Message *)[self.messages lastObject]).mid; if (![self.path isEqualToString:[Message threadUrl]]) { [self.params setValue:lastMid forKey:@"before_mid"]; } -- cgit v1.2.3