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

@@ -14,6 +14,7 @@
#import "HomeRankCardCell.h"
#import "KBHomeVM.h"
#import "KBCharacter.h"
#import "KBMyVM.h" //
@interface HomeRankContentVC ()
@property (nonatomic, copy, nullable) NSString *tagId; // id
@@ -46,14 +47,29 @@
make.edges.equalTo(self.view);
}];
//
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(kb_onUserCharacterDeleted:)
name:KBUserCharacterDeletedNotification
object:nil];
// tag
[self loadCharactersForCurrentTag];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)loadCharactersForCurrentTag {
[self kb_requestCharactersWithShowHUD:YES];
}
// tag
- (void)kb_requestCharactersWithShowHUD:(BOOL)needShow {
KBWeakSelf
[self.homeVM fetchRankListByTagId:self.tagId
needShow:YES
needShow:needShow
completion:^(NSArray<KBCharacter *> * _Nullable list, NSError * _Nullable error) {
if (error) {
return;
@@ -63,6 +79,26 @@
}];
}
/// id
- (void)kb_onUserCharacterDeleted:(NSNotification *)note {
NSNumber *cid = note.userInfo[@"characterId"];
if (!cid) { return; }
NSInteger targetId = cid.integerValue;
if (targetId <= 0) { return; }
BOOL contains = NO;
for (KBCharacter *c in self.characters) {
if (c.characterId.integerValue == targetId) {
contains = YES;
break;
}
}
if (!contains) { return; }
// added UI
[self kb_requestCharactersWithShowHUD:NO];
}
- (UICollectionView *)collectionView{
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];