This commit is contained in:
2025-12-04 16:59:59 +08:00
parent f593ef0b4a
commit 8f63741d8c
5 changed files with 94 additions and 6 deletions

View File

@@ -11,6 +11,11 @@
NS_ASSUME_NONNULL_BEGIN
/// 用户人设发生变更(例如从“我的键盘”中删除)时的进程内通知。
/// userInfo:
/// @"characterId" : NSNumber(NSInteger) 被删除或变更的人设 id
extern NSString * const KBUserCharacterDeletedNotification;
typedef void(^KBMyUserDetailCompletion)(KBUser *_Nullable user, NSError *_Nullable error);
typedef void(^KBCharacterListCompletion)(NSArray<KBCharacter *> *characterArray, NSError *_Nullable error);
typedef void(^KBUpLoadAvatarCompletion)(BOOL success, NSError * _Nullable error);

View File

@@ -11,6 +11,8 @@
#import "KBUser.h"
#import "KBAPI.h"
NSString * const KBUserCharacterDeletedNotification = @"KBUserCharacterDeletedNotification";
@implementation KBMyVM
- (void)fetchUserDetailWithCompletion:(KBMyUserDetailCompletion)completion {
@@ -111,7 +113,6 @@
}
NSDictionary *params = @{@"id": characterId};
[KBHUD show];
[[KBNetworkManager shared] GET:API_CHARACTER_DEL_USER_CHARACTER
parameters:params
headers:nil
@@ -119,9 +120,20 @@
completion:^(NSDictionary *jsonOrData,
NSURLResponse * _Nullable response,
NSError * _Nullable error) {
[KBHUD dismiss];
BOOL success = (error == nil);
if (success) {
// App HomeRankContentVC / HomeHotVC
NSDictionary *info = @{@"characterId": characterId ?: @0};
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:KBUserCharacterDeletedNotification
object:nil
userInfo:info];
});
}
if (completion) {
completion(error == nil, error);
completion(success, error);
}
}];
}