Skip to content

Commit 750d84a

Browse files
guangyaoguangyao
authored andcommitted
Fix 黑名单和清空历史记录的问题
1 parent 543e59e commit 750d84a

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

ios/RNNeteaseIm/RNNeteaseIm/BankListViewController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ -(void)initWithDelegate{
3232
}
3333
-(void)getBlackList{
3434
NSMutableArray *list = [[NSMutableArray alloc] init];
35-
for (NIMUser *user in [NIMSDK sharedSDK].userManager.myBlackList) {
35+
NSArray *blackList = [NIMSDK sharedSDK].userManager.myBlackList;
36+
for (NIMUser *user in blackList) {
3637
NIMKitInfo *info = [[NIMKit sharedKit] infoByUser:user.userId option:nil];
3738
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
3839
[dic setObject:[NSString stringWithFormat:@"%@", info.showName] forKey:@"name"];

ios/RNNeteaseIm/RNNeteaseIm/ContactViewController.m

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,21 @@ -(void)getFriendList:(Success )success error:(Error )error{
9696
-(void)getAllContactFriends{
9797

9898
NSMutableArray *contacts = [NSMutableArray array];
99+
NSArray *blackList = [NIMSDK sharedSDK].userManager.myBlackList;
99100
for (NIMUser *user in [NIMSDK sharedSDK].userManager.myFriends) {
100-
NIMKitInfo *info = [[NIMKit sharedKit] infoByUser:user.userId option:nil];
101-
_contacts = [[NTESContactDataMember alloc] init];
102-
_contacts.info = info;
103-
[contacts addObject:_contacts];
101+
BOOL isBlack = NO;
102+
for (NIMUser *blackUser in blackList) {
103+
if ([user.userId isEqualToString:blackUser.userId]) {
104+
isBlack = YES;
105+
break;
106+
}
107+
}
108+
if (!isBlack) {
109+
NIMKitInfo *info = [[NIMKit sharedKit] infoByUser:user.userId option:nil];
110+
_contacts = [[NTESContactDataMember alloc] init];
111+
_contacts.info = info;
112+
[contacts addObject:_contacts];
113+
}
104114
}
105115
[self setMembers:contacts];
106116
}

ios/RNNeteaseIm/RNNeteaseIm/ConversationViewController.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,9 @@ -(void)deleteMsg:(NSString *)messageId{
10701070
//清空聊天记录
10711071
-(void)clearMsg:(NSString *)contactId type:(NSString *)type{
10721072
NIMSession *session = [NIMSession session:contactId type:[type integerValue]];
1073-
[[NIMSDK sharedSDK].conversationManager deleteAllmessagesInSession:session option:NO];
1073+
NIMDeleteMessagesOption *option = [[NIMDeleteMessagesOption alloc]init];
1074+
option.removeSession = NO;
1075+
[[NIMSDK sharedSDK].conversationManager deleteAllmessagesInSession:session option:option];
10741076
// [[NIMSDK sharedSDK].conversationManager deleteAllmessagesInSession:session removeRecentSession:NO];
10751077
}
10761078
- (NIMMessage *)msgWithTip:(NSString *)tip

ios/RNNeteaseIm/RNNeteaseIm/NIMModel.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ -(void)setNIMKick:(NSString *)NIMKick{
5050
}
5151
}
5252
}
53+
//通信录列表
5354
-(void)setContactList:(NSMutableDictionary *)contactList{
5455
if (_contactList != contactList) {
5556
_contactList = contactList;
@@ -125,11 +126,8 @@ -(void)setSendState:(NSMutableArray *)sendState{
125126
}
126127
//黑名单列表
127128
-(void)setBankList:(NSMutableArray *)bankList{
128-
if (bankList.count) {
129129
if (self.myBlock) {
130130
self.myBlock(13, bankList);
131-
}
132-
133131
}
134132
}
135133

ios/RNNeteaseIm/RNNeteaseIm/NIMViewController.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ -(void)deleteCurrentSession:(NSString *)recentContactId andback:(ERROR)error{
8989
for (NIMRecentSession *recent in NIMlistArr) {
9090
if ([recent.session.sessionId isEqualToString:recentContactId]) {
9191
id<NIMConversationManager> manager = [[NIMSDK sharedSDK] conversationManager];
92-
[manager deleteRecentSession:recent];
92+
// [manager deleteRecentSession:recent];
93+
NIMDeleteMessagesOption *option = [[NIMDeleteMessagesOption alloc]init];
94+
option.removeSession = YES;
95+
[manager deleteAllmessagesInSession:recent.session option:option];
96+
//清除历史记录
9397
[self getResouces];
9498
}
9599
}

0 commit comments

Comments
 (0)