summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Juick/APIClient.m32
1 files changed, 17 insertions, 15 deletions
diff --git a/Juick/APIClient.m b/Juick/APIClient.m
index f2eeb29..24efc60 100644
--- a/Juick/APIClient.m
+++ b/Juick/APIClient.m
@@ -158,23 +158,25 @@
}
-(void) fetchChatWithUser:(NSString *)uname callback:(void (^)(NSArray *, NSError *))callback {
NSDictionary *params = @{@"uname": uname};
- [self.backgroundQueue addOperationWithBlock:^{
- [self.manager GET:@"pm" parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
- NSMutableArray *messages = [NSMutableArray new];
- NSArray *messagesList = (NSArray *)responseObject;
- [messagesList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- [messages addObject:[Message fromJSON:obj]];
- }];
- [[NSOperationQueue mainQueue] addOperationWithBlock:^{
- callback(messages, nil);
- }];
- } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
- NSLog(@"Error: %@", [error localizedDescription]);
- [[NSOperationQueue mainQueue] addOperationWithBlock:^{
- callback(nil, error);
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ [self.backgroundQueue addOperationWithBlock:^{
+ [self.manager GET:@"pm" parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
+ NSMutableArray *messages = [NSMutableArray new];
+ NSArray *messagesList = (NSArray *)responseObject;
+ [messagesList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+ [messages addObject:[Message fromJSON:obj]];
+ }];
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ callback(messages, nil);
+ }];
+ } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
+ NSLog(@"Error: %@", [error localizedDescription]);
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ callback(nil, error);
+ }];
}];
}];
- }];
+ });
}
-(void) authenticate:(void (^)(User *user, NSError *error))callback {
[self.manager GET:@"me" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {