This commit is contained in:
2025-12-04 19:12:34 +08:00
parent 8f63741d8c
commit 64887054e0
18 changed files with 331 additions and 50 deletions

View File

@@ -109,7 +109,9 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
for (KBCharacter *c in characterArray) {
NSString *emoji = c.emoji ?: @"";
NSString *title = c.characterName ?: @"";
NSString *identifier = c.characterId ?: @"";
NSString *identifier = c.ID ?: @"";
NSString *characterId = c.characterId ?: @"";
// emoji
if (emoji.length == 0 && title.length == 0) {
continue;
@@ -117,6 +119,8 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
NSMutableDictionary *item = [NSMutableDictionary dictionary];
item[@"emoji"] = emoji;
item[@"title"] = title;
item[@"characterId"] = characterId;
if (identifier.length > 0) {
// 便 sort
NSInteger cid = identifier.integerValue;
@@ -154,18 +158,21 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
if (!tapIndexPath) { return; }
// id
NSNumber *characterId = nil;
NSNumber *delId = nil; // ID
NSString *characterId = @""; // ID
if (tapIndexPath.section < self.dataSourceArray.count) {
NSArray *section = self.dataSourceArray[tapIndexPath.section];
if (tapIndexPath.item < section.count) {
NSDictionary *item = section[tapIndexPath.item];
id cid = item[@"id"];
characterId = item[@"characterId"];
if ([cid isKindOfClass:[NSNumber class]]) {
characterId = (NSNumber *)cid;
delId = (NSNumber *)cid;
} else if ([cid isKindOfClass:[NSString class]]) {
NSString *cidStr = (NSString *)cid;
if (cidStr.length > 0) {
characterId = @([cidStr integerValue]);
delId = @([cidStr integerValue]);
}
}
}
@@ -181,7 +188,7 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
if (!ok) { return; }
// id UI
if (!characterId) {
if (!delId) {
if (tapIndexPath.section < self.dataSourceArray.count) {
NSMutableArray *section = self.dataSourceArray[tapIndexPath.section];
if (tapIndexPath.item < section.count) {
@@ -196,7 +203,7 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
//
__weak typeof(self) weakSelf2 = self;
[self.viewModel deleteUserCharacterWithId:characterId
[self.viewModel deleteUserCharacterWithId:delId
completion:^(BOOL success, NSError * _Nullable error) {
__strong typeof(weakSelf2) strongSelf = weakSelf2;
if (!strongSelf) { return; }
@@ -206,7 +213,13 @@ static NSString * const kKBMyKeyboardCellId = @"kKBMyKeyboardCellId";
[KBHUD showInfo:msg];
return;
}
// App HomeRankContentVC / HomeHotVC
NSDictionary *info = @{@"characterId": characterId ?: @0};
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:KBUserCharacterDeletedNotification
object:nil
userInfo:info];
});
// UI
[strongSelf kb_reloadUserCharacters];
}];