Skip to content

Commit 64917ec

Browse files
committed
chore: tweak code
1 parent 1d1458b commit 64917ec

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

AVOS/Sources/Foundation/User/LCFriendship.m

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ + (void)requestWithUserId:(NSString *)userId callback:(void (^)(BOOL, NSError *
3838
+ (void)requestWithUserId:(NSString *)userId attributes:(NSDictionary *)attributes callback:(void (^)(BOOL, NSError * _Nullable))callback {
3939
if (!userId) {
4040
NSError *error = LCError(LCErrorInternalErrorCodeInconsistency, @"Parameter `userId` invalid.", nil);
41-
callback(false, error);
41+
dispatch_async(dispatch_get_main_queue(), ^{
42+
callback(false, error);
43+
});
4244
return;
4345
}
4446
LCUser *currentUser = [LCUser currentUser];
4547
if (!currentUser.sessionToken) {
4648
NSError *error = LCError(LCErrorInternalErrorCodeInconsistency, @"Please signin an user.", nil);
47-
callback(false, error);
49+
dispatch_async(dispatch_get_main_queue(), ^{
50+
callback(false, error);
51+
});
4852
return;
4953
}
5054
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
@@ -69,13 +73,17 @@ + (void)acceptRequest:(LCFriendshipRequest *)request callback:(void (^)(BOOL, NS
6973
+ (void)acceptRequest:(LCFriendshipRequest *)request attributes:(NSDictionary *)attributes callback:(void (^)(BOOL, NSError * _Nullable))callback {
7074
if (!request.objectId) {
7175
NSError *error = LCError(LCErrorInternalErrorCodeInconsistency, @"Parameter `request` invalid.", nil);
72-
callback(false, error);
76+
dispatch_async(dispatch_get_main_queue(), ^{
77+
callback(false, error);
78+
});
7379
return;
7480
}
7581
LCUser *currentUser = [LCUser currentUser];
7682
if (!currentUser.sessionToken) {
7783
NSError *error = LCError(LCErrorInternalErrorCodeInconsistency, @"Please signin an user.", nil);
78-
callback(false, error);
84+
dispatch_async(dispatch_get_main_queue(), ^{
85+
callback(false, error);
86+
});
7987
return;
8088
}
8189
NSString *path = [NSString stringWithFormat:@"users/friendshipRequests/%@/accept", request.objectId];
@@ -96,13 +104,17 @@ + (void)acceptRequest:(LCFriendshipRequest *)request attributes:(NSDictionary *)
96104
+ (void)declineRequest:(LCFriendshipRequest *)request callback:(void (^)(BOOL, NSError * _Nullable))callback {
97105
if (!request.objectId) {
98106
NSError *error = LCError(LCErrorInternalErrorCodeInconsistency, @"Parameter `request` invalid.", nil);
99-
callback(false, error);
107+
dispatch_async(dispatch_get_main_queue(), ^{
108+
callback(false, error);
109+
});
100110
return;
101111
}
102112
LCUser *currentUser = [LCUser currentUser];
103113
if (!currentUser.sessionToken) {
104114
NSError *error = LCError(LCErrorInternalErrorCodeInconsistency, @"Please signin an user.", nil);
105-
callback(false, error);
115+
dispatch_async(dispatch_get_main_queue(), ^{
116+
callback(false, error);
117+
});
106118
return;
107119
}
108120
NSString *path = [NSString stringWithFormat:@"users/friendshipRequests/%@/decline", request.objectId];

0 commit comments

Comments
 (0)