1
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#import "HomeRankDetailPopView.h"
|
||||
#import "LSTPopView.h"
|
||||
#import <HWPanModal/HWPanModal.h>
|
||||
#import "KBMyVM.h" // 用户人设变更通知
|
||||
|
||||
@interface HomeHotVC () <UITableViewDataSource, UITableViewDelegate>
|
||||
|
||||
@@ -53,9 +54,24 @@
|
||||
|
||||
// 请求排行榜数据
|
||||
self.homeVM = [KBHomeVM new];
|
||||
[self kb_reloadRankListWithShowHUD:YES];
|
||||
|
||||
// 监听“用户人设删除”通知,用于同步更新加号按钮状态
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(kb_onUserCharacterDeleted:)
|
||||
name:KBUserCharacterDeletedNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
/// 拉取首页排行榜数据
|
||||
- (void)kb_reloadRankListWithShowHUD:(BOOL)needShow {
|
||||
KBWeakSelf
|
||||
[self.homeVM fetchRankListWithParams:nil
|
||||
needShow:YES
|
||||
needShow:needShow
|
||||
completion:^(NSArray<KBCharacter *> * _Nullable list, NSError * _Nullable error) {
|
||||
if (error) {
|
||||
// 错误提示已经在 VM 内部通过 HUD 处理,这里不再重复提示
|
||||
@@ -104,6 +120,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.allCharacters) {
|
||||
if (c.characterId.integerValue == targetId) {
|
||||
contains = YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!contains) { return; }
|
||||
|
||||
// 刷新首页排行榜数据(不需要 HUD)
|
||||
[self kb_reloadRankListWithShowHUD:NO];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDataSource
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
|
||||
Reference in New Issue
Block a user