|
@@ -73,20 +73,22 @@ static CGFloat textFieldH = 56;
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(momentsUpdateType:) name:@"SLMomentsUpdateType" object:nil];
|
|
|
|
|
|
[self creatModelsWithCount:0];
|
|
|
- if (!self.isDetail) {
|
|
|
+ if (!self.isDetail && !self.dataArray.count) {
|
|
|
NSString *cacheKey = [NSString stringWithFormat:@"SLMomentsCache--%@--%@", self.userModel.userId,@(self.isFriendList)];
|
|
|
NSString *cacheStr = [[NSUserDefaults standardUserDefaults] objectForKey:cacheKey];
|
|
|
NSArray *items = [[cacheStr mj_JSONObject] objectForKey:@"items"];
|
|
|
if (items.count) {
|
|
|
NSArray<SDTimeLineCellModel *> *models = [SDTimeLineCellModel mj_objectArrayWithKeyValuesArray:items];
|
|
|
self.currentCacheFriendId = models.firstObject.friendId;
|
|
|
- [self.dataArray addObjectsFromArray:models];
|
|
|
+ if (!self.dataArray.count) {
|
|
|
+ [self.dataArray addObjectsFromArray:models];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if ([self.userModel.userId isEqualToString:[SLGlobalInfo SharedInstance].loginInfo.user.userId] && !self.isFriendList) {
|
|
|
WS(weakSelf);
|
|
|
[self.KVOController observe:[SLGlobalInfo SharedInstance] keyPath:@"loginInfo" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld block:^(id _Nullable observer, id _Nonnull object, NSDictionary<NSKeyValueChangeKey,id> * _Nonnull change) {
|
|
|
- [weakSelf updateTableViewHeaderView];
|
|
|
+ [weakSelf updateTableViewHeaderView:YES];
|
|
|
}];
|
|
|
}
|
|
|
}
|
|
@@ -109,7 +111,7 @@ static CGFloat textFieldH = 56;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)updateTableViewHeaderView {
|
|
|
+- (void)updateTableViewHeaderView:(BOOL)needReload {
|
|
|
[self.headerView confignHeaderWith:self.userModel];
|
|
|
SLUserModel *userModel = [SLGlobalInfo SharedInstance].loginInfo.user;
|
|
|
if ([self.userModel.userId isEqualToString:userModel.userId]) {
|
|
@@ -127,6 +129,9 @@ static CGFloat textFieldH = 56;
|
|
|
self.rdv_tabBarItem.badgeValue = unReadCount < 99 ? [NSString stringWithFormat:@"%ld",unReadCount] : @"99+";
|
|
|
self.rdv_tabBarItem.badgePositionAdjustment = UIOffsetMake(-10, 0);
|
|
|
self.rdv_tabBarItem.badgeTextFont = [UIFont systemFontOfSize:10];
|
|
|
+ if (needReload) {
|
|
|
+ [self.tableView reloadData];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -137,7 +142,7 @@ static CGFloat textFieldH = 56;
|
|
|
self.userModel = [SLGlobalInfo SharedInstance].loginInfo.user;
|
|
|
}
|
|
|
if ([self.tableView.tableHeaderView isKindOfClass:SDTimeLineTableHeaderView.class]) {
|
|
|
- [self updateTableViewHeaderView];
|
|
|
+ [self updateTableViewHeaderView:NO];
|
|
|
}
|
|
|
if (self.tableView.contentOffset.y < 300 && !self.tableView.mj_header.refreshing) {
|
|
|
[self.tableView.mj_header beginRefreshing];
|
|
@@ -305,7 +310,7 @@ static CGFloat textFieldH = 56;
|
|
|
[[SLHttpCenter SharedInstance] getWithUrl:url parameter:parameter success:^(id responseObject) {
|
|
|
NSDictionary *data = [responseObject objectForKey:@"data"];
|
|
|
[SLGlobalInfo SharedInstance].loginInfo.user.momentsMsgNotice = [[data objectForKey:@"unread"] stringValue];
|
|
|
- [self updateTableViewHeaderView];
|
|
|
+ [self updateTableViewHeaderView:NO];
|
|
|
NSArray *items = [data objectForKey:@"items"];
|
|
|
if (items.count) {
|
|
|
NSMutableArray *marr = [SDTimeLineCellModel mj_objectArrayWithKeyValuesArray:items];
|
|
@@ -361,9 +366,6 @@ static CGFloat textFieldH = 56;
|
|
|
self.navigationBar.rightBarButtonItemView.itemImageView.image = ImageName(@"icon_pyq_more_back");
|
|
|
self.navigationBar.titleItemView.alpha = alpha;
|
|
|
self.navigationBar.leftBarButtonItemView.itemImageView.image = ImageName(@"icon_back_b");
|
|
|
-
|
|
|
- if (self.isFriendList) {
|
|
|
- }
|
|
|
} else {
|
|
|
self.navigationBar.titleItemView.alpha = 0;
|
|
|
self.navigationBar.backgroundColor = [color colorWithAlphaComponent:0];
|