diff options
author | Vitaly Takmazov | 2016-12-22 20:02:37 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-12-22 20:02:37 +0300 |
commit | 87c992e9db9464215d12a3987fe384d65e96bc50 (patch) | |
tree | a50471f97c74a78ba2d89f49a7a7e473115cf0a7 /Juick | |
parent | b3de91bba52f309df4eabdd30b8cd189f0b3bdae (diff) |
refactoring
Diffstat (limited to 'Juick')
-rw-r--r-- | Juick/Model/Message.h | 4 | ||||
-rw-r--r-- | Juick/Model/Message.m | 4 | ||||
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.m | 12 |
3 files changed, 10 insertions, 10 deletions
diff --git a/Juick/Model/Message.h b/Juick/Model/Message.h index b100e7d..438f693 100644 --- a/Juick/Model/Message.h +++ b/Juick/Model/Message.h @@ -11,8 +11,8 @@ @interface Message : NSObject -@property NSNumber *MID; -@property NSNumber *RID; +@property NSNumber *mid; +@property NSNumber *rid; @property User *user; @property NSString *text; @property NSArray<NSString *> *tags; diff --git a/Juick/Model/Message.m b/Juick/Model/Message.m index de08e98..a4bcd2c 100644 --- a/Juick/Model/Message.m +++ b/Juick/Model/Message.m @@ -13,8 +13,8 @@ + (NSDictionary *)modelCustomPropertyMapper { return @{@"text" : @"body", - @"MID" : @"mid", - @"RID" : @"rid", + @"mid" : @"mid", + @"rid" : @"rid", @"attach" : @"photo.small", @"repliesCount": @"replies", @"repliesBy": @"repliesby"}; 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"]; } |