Browse Source

解决同步大量消息和大量好友和大量群组导致UI卡顿问题

heavyrian2012 2 years ago
parent
commit
93d42dfdb0

+ 6 - 2
wfchat/WildFireChat/Me/WFCMeTableViewController.m

@@ -64,8 +64,12 @@
     
     __weak typeof(self)ws = self;
     [[NSNotificationCenter defaultCenter] addObserverForName:kUserInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
-        if ([[WFCCNetworkService sharedInstance].userId isEqualToString:note.object]) {
-            [ws.tableView reloadData];
+        NSArray<WFCCUserInfo *> *userInfoList = note.userInfo[@"userInfoList"];
+        for (WFCCUserInfo *userInfo in userInfoList) {
+            if ([[WFCCNetworkService sharedInstance].userId isEqualToString:userInfo.userId]) {
+                [ws.tableView reloadData];
+                break;
+            }
         }
     }];
     

+ 9 - 6
wfuikit/WFChatUIKit/Channel/WFCUFavChannelTableViewController.m

@@ -62,13 +62,16 @@
 }
 
 - (void)onChannelInfoUpdated:(NSNotification *)notification {
-    WFCCChannelInfo *channelInfo = notification.userInfo[@"channelInfo"];
     BOOL updated = NO;
-    for (int i = 0; i < self.favChannels.count; i++) {
-        if([self.favChannels[i].channelId isEqualToString:channelInfo.channelId]) {
-            self.favChannels[i] = channelInfo;
-            [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:1]] withRowAnimation:UITableViewRowAnimationFade];
-            updated = YES;
+    NSArray<WFCCChannelInfo *> *channelInfoList = notification.userInfo[@"channelInfoList"];
+    for (WFCCChannelInfo *channelInfo in channelInfoList) {
+        for (int i = 0; i < self.favChannels.count; i++) {
+            if([self.favChannels[i].channelId isEqualToString:channelInfo.channelId]) {
+                self.favChannels[i] = channelInfo;
+                [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:1]] withRowAnimation:UITableViewRowAnimationFade];
+                updated = YES;
+                break;
+            }
         }
     }
     

+ 8 - 5
wfuikit/WFChatUIKit/CommonVC/WFCUProfileTableViewController.m

@@ -62,11 +62,14 @@
     self.title = WFCString(@"UserInfomation");
     __weak typeof(self)ws = self;
     [[NSNotificationCenter defaultCenter] addObserverForName:kUserInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
-        if ([ws.userId isEqualToString:note.object]) {
-            WFCCUserInfo *userInfo = note.userInfo[@"userInfo"];
-            ws.userInfo = userInfo;
-            [ws loadData];
-            NSLog(@"reload user info %@", ws.userInfo.userId);
+        NSArray<WFCCUserInfo *> *userInfoList = note.userInfo[@"userInfoList"];
+        for (WFCCUserInfo *userInfo in userInfoList) {
+            if ([ws.userId isEqualToString:userInfo.userId]) {
+                WFCCUserInfo *userInfo = note.userInfo[@"userInfo"];
+                ws.userInfo = userInfo;
+                [ws loadData];
+                break;
+            }
         }
     }];
     

+ 6 - 3
wfuikit/WFChatUIKit/Contacts/Cell/WFCUContactTableViewCell.m

@@ -46,9 +46,12 @@
       }
 }
 - (void)onUserInfoUpdated:(NSNotification *)notification {
-    WFCCUserInfo *userInfo = notification.userInfo[@"userInfo"];
-    if ([self.userId isEqualToString:userInfo.userId]) {
-        [self updateUserInfo:userInfo];
+    NSArray<WFCCUserInfo *> *userInfoList = notification.userInfo[@"userInfoList"];
+    for (WFCCUserInfo *userInfo in userInfoList) {
+        if ([self.userId isEqualToString:userInfo.userId]) {
+            [self updateUserInfo:userInfo];
+            break;
+        }
     }
 }
 

+ 8 - 6
wfuikit/WFChatUIKit/Contacts/ViewController/WFCUContactListViewController.m

@@ -245,15 +245,17 @@ static NSString *wfcstar = @"☆";
 }
 
 - (void)onUserInfoUpdated:(NSNotification *)notification {
-    WFCCUserInfo *userInfo = notification.userInfo[@"userInfo"];
     BOOL needRefresh = NO;
-    for (WFCCUserInfo *ui in self.dataArray) {
-        if ([ui.userId isEqualToString:userInfo.userId]) {
-            needRefresh = YES;
-            [ui cloneFrom:userInfo];
-            break;
+    NSArray<WFCCUserInfo *> *userInfoList = notification.userInfo[@"userInfoList"];
+    for (WFCCUserInfo *userInfo in userInfoList) {
+        for (WFCCUserInfo *ui in self.dataArray) {
+            if ([ui.userId isEqualToString:userInfo.userId]) {
+                needRefresh = YES;
+                [ui cloneFrom:userInfo];
+            }
         }
     }
+    
     if(needRefresh) {
         self.needSort = needRefresh;
     }

+ 58 - 1
wfuikit/WFChatUIKit/ConversationList/Cell/WFCUConversationTableViewCell.m

@@ -36,6 +36,7 @@
 
 }
 - (void)updateUserInfo:(WFCCUserInfo *)userInfo {
+  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUserInfoUpdated:) name:kUserInfoUpdated object:nil];
   [self.potraitView sd_setImageWithURL:[NSURL URLWithString:[userInfo.portrait stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] placeholderImage: [WFCUImage imageNamed:@"PersonalChat"]];
   
     if (userInfo.friendAlias.length) {
@@ -48,6 +49,8 @@
 }
 
 - (void)updateChannelInfo:(WFCCChannelInfo *)channelInfo {
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onChannelInfoUpdated:) name:kChannelInfoUpdated object:nil];
+    
     [self.potraitView sd_setImageWithURL:[NSURL URLWithString:[channelInfo.portrait stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] placeholderImage:[WFCUImage imageNamed:@"channel_default_portrait"]];
     
     if(channelInfo.name.length > 0) {
@@ -59,7 +62,9 @@
 
 - (void)updateGroupInfo:(WFCCGroupInfo *)groupInfo {
     [[NSNotificationCenter defaultCenter] removeObserver:self name:@"GroupPortraitChanged" object:nil];
-
+    
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onGroupInfoUpdated:) name:kGroupInfoUpdated object:nil];
+    
     if (groupInfo.portrait.length) {
         [self.potraitView sd_setImageWithURL:[NSURL URLWithString:[groupInfo.portrait stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] placeholderImage:[WFCUImage imageNamed:@"group_default_portrait"]];
     } else {
@@ -174,7 +179,10 @@
         _digestView.frame = CGRectMake(16 + 48 + 12, 40, [UIScreen mainScreen].bounds.size.width - 76 - 16 - 16, 19);
     }
 }
+
 - (void)update:(WFCCConversation *)conversation {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    
     self.targetView.textColor = [WFCUConfigManager globalManager].textColor;
     if(conversation.type == Single_Type) {
         WFCCUserInfo *userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:conversation.target refresh:NO];
@@ -287,6 +295,55 @@
     }
 }
 
+- (void)reloadCell {
+    [self setInfo:self.info];
+}
+
+- (void)onUserInfoUpdated:(NSNotification *)notification {
+    NSArray<WFCCUserInfo *> *userInfoList = notification.userInfo[@"userInfoList"];
+    WFCCConversationInfo *conv = self.info;
+    
+    for (WFCCUserInfo *userInfo in userInfoList) {
+        if (conv.conversation.type == Single_Type || conv.conversation.type == SecretChat_Type) {
+            if([userInfo.userId isEqualToString:conv.conversation.target]) {
+                [self reloadCell];
+                break;
+            }
+        }
+     
+        if ([conv.lastMessage.fromUser isEqualToString:userInfo.userId]) {
+            [self reloadCell];
+            break;
+        }
+    }
+}
+
+- (void)onGroupInfoUpdated:(NSNotification *)notification {
+    NSArray<WFCCGroupInfo *> *groupInfoList = notification.userInfo[@"groupInfoList"];
+    WFCCConversationInfo *conv = self.info;
+    if(conv.conversation.type == Group_Type) {
+        for (WFCCGroupInfo *groupInfo in groupInfoList) {
+            if ([conv.conversation.target isEqualToString:groupInfo.target]) {
+                [self reloadCell];
+                break;
+            }
+        }
+    }
+}
+
+- (void)onChannelInfoUpdated:(NSNotification *)notification {
+    NSArray<WFCCChannelInfo *> *channelInfoList = notification.userInfo[@"channelInfoList"];
+    WFCCConversationInfo *conv = self.info;
+    if(conv.conversation.type == Channel_Type) {
+        for (WFCCChannelInfo *channelInfo in channelInfoList) {
+            if ([conv.conversation.target isEqualToString:channelInfo.channelId]) {
+                [self reloadCell];
+                break;
+            }
+        }
+    }
+}
+
 - (UIImageView *)potraitView {
     if (!_potraitView) {
         _potraitView = [[UIImageView alloc] initWithFrame:CGRectMake(16, 12, 48, 48)];

+ 1 - 40
wfuikit/WFChatUIKit/ConversationList/ViewController/WFCUConversationTableViewController.m

@@ -105,58 +105,19 @@
 - (void)onUserInfoUpdated:(NSNotification *)notification {
     if (self.searchController.active) {
         [self.tableView reloadData];
-    } else {
-        WFCCUserInfo *userInfo = notification.userInfo[@"userInfo"];
-        NSArray *dataSource = self.conversations;
-        for (int i = 0; i < dataSource.count; i++) {
-            WFCCConversationInfo *conv = dataSource[i];
-            if (conv.conversation.type == Single_Type && [conv.conversation.target isEqualToString:userInfo.userId]) {
-                [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
-            } else if ([conv.lastMessage.fromUser isEqualToString:userInfo.userId]) {
-                [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
-            } else if(conv.conversation.type == SecretChat_Type) {
-                NSString *userId = [[WFCCIMService sharedWFCIMService] getSecretChatInfo:conv.conversation.target].userId;
-                if([userInfo.userId isEqualToString:userId]) {
-                    [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
-                }
-            }
-            
-        }
     }
 }
 
 - (void)onGroupInfoUpdated:(NSNotification *)notification {
     if (self.searchController.active) {
         [self.tableView reloadData];
-    } else {
-        WFCCGroupInfo *groupInfo = notification.userInfo[@"groupInfo"];
-        NSArray *dataSource = self.conversations;
-        
-        
-        for (int i = 0; i < dataSource.count; i++) {
-            WFCCConversationInfo *conv = dataSource[i];
-            if (conv.conversation.type == Group_Type && [conv.conversation.target isEqualToString:groupInfo.target]) {
-                [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
-            }
-        }
     }
 }
 
 - (void)onChannelInfoUpdated:(NSNotification *)notification {
     if (self.searchController.active) {
         [self.tableView reloadData];
-    } else {
-        WFCCChannelInfo *channelInfo = notification.userInfo[@"groupInfo"];
-        NSArray *dataSource = self.conversations;
-        
-        
-        for (int i = 0; i < dataSource.count; i++) {
-            WFCCConversationInfo *conv = dataSource[i];
-            if (conv.conversation.type == Channel_Type && [conv.conversation.target isEqualToString:channelInfo.channelId]) {
-                [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
-            }
-        }
-    }
+    } 
 }
 
 - (void)onSendingMessageStatusUpdated:(NSNotification *)notification {

+ 7 - 3
wfuikit/WFChatUIKit/ConversationSetting/ViewController/GroupManageTableViewController.m

@@ -37,9 +37,13 @@
     
     __weak typeof(self)ws = self;
     [[NSNotificationCenter defaultCenter] addObserverForName:kGroupInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
-        if ([ws.groupInfo.target isEqualToString:note.object]) {
-            ws.groupInfo = [[WFCCIMService sharedWFCIMService] getGroupInfo:ws.groupInfo.target refresh:NO];
-            [ws.tableView reloadData];
+        NSArray<WFCCGroupInfo *> *groupInfoList = note.userInfo[@"groupInfoList"];
+        for (WFCCGroupInfo *groupInfo in groupInfoList) {
+            if ([ws.groupInfo.target isEqualToString:groupInfo.target]) {
+                ws.groupInfo = groupInfo;
+                [ws.tableView reloadData];
+                break;
+            }
         }
     }];
     

+ 7 - 6
wfuikit/WFChatUIKit/FriendRequest/ViewController/WFCUFriendRequestViewController.m

@@ -33,12 +33,13 @@
 }
 
 - (void)onUserInfoUpdated:(NSNotification *)notification {
-    WFCCUserInfo *userInfo = notification.userInfo[@"userInfo"];
-    NSArray *dataSource = self.dataList;
-    for (int i = 0; i < dataSource.count; i++) {
-        WFCCFriendRequest *request = dataSource[i];
-        if ([request.target isEqualToString:userInfo.userId]) {
-            [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
+    NSArray<WFCCUserInfo *> *userInfoList = notification.userInfo[@"userInfoList"];
+    for (int i = 0; i < self.dataList.count; ++i) {
+        WFCCFriendRequest *request = self.dataList[i];
+        for (WFCCUserInfo *userInfo in userInfoList) {
+            if([userInfo.userId isEqualToString:request.target]) {
+                [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
+            }
         }
     }
 }

+ 7 - 5
wfuikit/WFChatUIKit/Group/ViewController/WFCUFavGroupTableViewController.m

@@ -45,11 +45,13 @@
 }
 
 - (void)onGroupInfoUpdated:(NSNotification *)notification {
-    WFCCGroupInfo *groupInfo = notification.userInfo[@"groupInfo"];
-    for (int i = 0; i < self.groups.count; i++) {
-        if([self.groups[i].target isEqualToString:groupInfo.target]) {
-            self.groups[i] = groupInfo;
-            [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
+    NSArray<WFCCGroupInfo *> *groupInfoList = notification.userInfo[@"groupInfoList"];
+    for (int i = 0; i < self.groups.count; ++i) {
+        for (WFCCGroupInfo *groupInfo in groupInfoList) {
+            if([self.groups[i].target isEqualToString:groupInfo.target]) {
+                self.groups[i] = groupInfo;
+                [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
+            }
         }
     }
 }

+ 6 - 3
wfuikit/WFChatUIKit/Group/ViewController/WFCUGroupInfoViewController.m

@@ -29,9 +29,12 @@
     
     __weak typeof(self)ws = self;
     [[NSNotificationCenter defaultCenter] addObserverForName:kGroupInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
-        if ([ws.groupId isEqualToString:note.object]) {
-            WFCCGroupInfo *groupInfo = note.userInfo[@"groupInfo"];
-            ws.groupInfo = groupInfo;
+        NSArray<WFCCGroupInfo *> *groupInfoList = note.userInfo[@"groupInfoList"];
+        for (WFCCGroupInfo *groupInfo in groupInfoList) {
+            if ([ws.groupId isEqualToString:groupInfo.target]) {
+                ws.groupInfo = groupInfo;
+                break;
+            }
         }
     }];
     

+ 7 - 4
wfuikit/WFChatUIKit/Group/ViewController/WFCUGroupTableViewController.m

@@ -26,10 +26,13 @@
 }
 
 - (void)onGroupInfoUpdated:(NSNotification *)notification {
-    WFCCGroupInfo *groupInfo = notification.userInfo[@"groupInfo"];
-    for (int i = 0; i < self.groupIds.count; i++) {
-        if([self.groupIds[i] isEqualToString:groupInfo.target]) {
-            [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
+    NSArray<WFCCGroupInfo *> *groupInfoList = notification.userInfo[@"groupInfoList"];
+    for (int i = 0; i < self.groupIds.count; ++i) {
+        for (WFCCGroupInfo *groupInfo in groupInfoList) {
+            if([self.groupIds[i] isEqualToString:groupInfo.target]) {
+                [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
+                break;
+            }
         }
     }
 }

+ 6 - 3
wfuikit/WFChatUIKit/Me/WFCUMyProfileTableViewController.m

@@ -48,9 +48,12 @@
 }
 
 - (void)onUserInfoUpdated:(NSNotification *)notification {
-    WFCCUserInfo *userInfo = notification.userInfo[@"userInfo"];
-    if ([[WFCCNetworkService sharedInstance].userId isEqualToString:userInfo.userId]) {
-        [self loadData:NO];
+    NSArray<WFCCUserInfo *> *userInfoList = notification.userInfo[@"userInfoList"];
+    for (WFCCUserInfo *userInfo in userInfoList) {
+        if ([[WFCCNetworkService sharedInstance].userId isEqualToString:userInfo.userId]) {
+            [self loadData:NO];
+            break;
+        }
     }
 }
 

+ 15 - 10
wfuikit/WFChatUIKit/MessageList/Cell/WFCUInformationCell.m

@@ -45,17 +45,22 @@
     __weak typeof(self)ws = self;
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [[NSNotificationCenter defaultCenter] addObserverForName:kUserInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
-        WFCCUserInfo *userInfo = note.userInfo[@"userInfo"];
+        NSArray<WFCCUserInfo *> *userInfoList = note.userInfo[@"userInfoList"];
+
         BOOL needUpdate = false;
-        if ([ws.model.message.content isKindOfClass:[WFCCAddGroupeMemberNotificationContent class]]) {
-            WFCCAddGroupeMemberNotificationContent *cnt = (WFCCAddGroupeMemberNotificationContent *)ws.model.message.content;
-            if ([cnt.invitor isEqualToString:userInfo.userId] || [cnt.invitees containsObject:userInfo.userId]) {
-                needUpdate = true;
-            }
-        } else if ([ws.model.message.content isKindOfClass:[WFCCCreateGroupNotificationContent class]]) {
-            WFCCCreateGroupNotificationContent *cnt = (WFCCCreateGroupNotificationContent *)ws.model.message.content;
-            if ([cnt.creator isEqualToString:userInfo.userId]) {
-                needUpdate = true;
+        for (WFCCUserInfo *userInfo in userInfoList) {
+            if ([ws.model.message.content isKindOfClass:[WFCCAddGroupeMemberNotificationContent class]]) {
+                WFCCAddGroupeMemberNotificationContent *cnt = (WFCCAddGroupeMemberNotificationContent *)ws.model.message.content;
+                if ([cnt.invitor isEqualToString:userInfo.userId] || [cnt.invitees containsObject:userInfo.userId]) {
+                    needUpdate = true;
+                    break;
+                }
+            } else if ([ws.model.message.content isKindOfClass:[WFCCCreateGroupNotificationContent class]]) {
+                WFCCCreateGroupNotificationContent *cnt = (WFCCCreateGroupNotificationContent *)ws.model.message.content;
+                if ([cnt.creator isEqualToString:userInfo.userId]) {
+                    needUpdate = true;
+                    break;
+                }
             }
         }
         

+ 13 - 7
wfuikit/WFChatUIKit/MessageList/Cell/WFCUMessageCell.m

@@ -147,13 +147,19 @@
         return;
     }
     
-  WFCCUserInfo *userInfo = notification.userInfo[@"userInfo"];
-  if([userInfo.userId isEqualToString:self.model.message.fromUser]) {
-      if (self.model.message.conversation.type == Group_Type) {
-          userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:userInfo.userId inGroup:self.model.message.conversation.target refresh:NO];
-      }
-    [self updateUserInfo:userInfo];
-  }
+    NSArray<WFCCUserInfo *> *userInfoList = notification.userInfo[@"userInfoList"];
+    for (WFCCUserInfo *userInfo in userInfoList) {
+        if([userInfo.userId isEqualToString:self.model.message.fromUser]) {
+            if (self.model.message.conversation.type == Group_Type) {
+                WFCCUserInfo *reloadUserInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:userInfo.userId inGroup:self.model.message.conversation.target refresh:NO];
+                [self updateUserInfo:reloadUserInfo];
+            } else {
+                [self updateUserInfo:userInfo];
+            }
+          
+            break;
+        }
+    }
 }
 
 - (void)updateChannelInfo:(WFCCChannelInfo *)channelInfo {

+ 19 - 14
wfuikit/WFChatUIKit/MessageList/ViewController/WFCUMessageListViewController.m

@@ -231,16 +231,24 @@
         }
     }
     
-    if(self.conversation.type == Single_Type) {
+    if(self.conversation.type == Single_Type || self.conversation.type == SecretChat_Type) {
         [[NSNotificationCenter defaultCenter] addObserverForName:kUserInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
-            if ([ws.conversation.target isEqualToString:note.object]) {
-                ws.targetUser = note.userInfo[@"userInfo"];
+            NSArray<WFCCUserInfo *> *userInfoList = note.userInfo[@"userInfoList"];
+            for (WFCCUserInfo *userInfo in userInfoList) {
+                if ([ws.conversation.target isEqualToString:note.object]) {
+                    ws.targetUser = note.userInfo[@"userInfo"];
+                    break;
+                }
             }
         }];
     } else if(self.conversation.type == Group_Type) {
         [[NSNotificationCenter defaultCenter] addObserverForName:kGroupInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
-            if ([ws.conversation.target isEqualToString:note.object]) {
-                ws.targetGroup = note.userInfo[@"groupInfo"];
+            NSArray<WFCCGroupInfo *> *groupInfoList = note.userInfo[@"groupInfoList"];
+            for (WFCCGroupInfo *groupInfo in groupInfoList) {
+                if ([ws.conversation.target isEqualToString:groupInfo.target]) {
+                    ws.targetGroup = groupInfo;
+                    break;
+                }
             }
         }];
         
@@ -252,15 +260,12 @@
         }];
     } else if(self.conversation.type == Channel_Type) {
         [[NSNotificationCenter defaultCenter] addObserverForName:kChannelInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
-            if ([ws.conversation.target isEqualToString:note.object]) {
-                ws.targetChannel = note.userInfo[@"channelInfo"];
-            }
-        }];
-    } else if(self.conversation.type == SecretChat_Type) {
-        NSString *userId = self.secretChatInfo.userId;
-        [[NSNotificationCenter defaultCenter] addObserverForName:kUserInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
-            if ([userId isEqualToString:note.object]) {
-                ws.targetUser = note.userInfo[@"userInfo"];
+            NSArray<WFCCChannelInfo *> *channelInfoList = note.userInfo[@"channelInfoList"];
+            for (WFCCChannelInfo *channelInfo in channelInfoList) {
+                if ([ws.conversation.target isEqualToString:channelInfo.channelId]) {
+                    ws.targetChannel = channelInfo;
+                    break;
+                }
             }
         }];
     }

+ 11 - 4
wfuikit/WFChatUIKit/Vendor/LBXScan/CreateBarCodeViewController.m

@@ -51,8 +51,12 @@
 //        self.qrStr = [NSString stringWithFormat:@"wildfirechat://user/%@?from=%@", self.target, [WFCCNetworkService sharedInstance].userId];
         
         [[NSNotificationCenter defaultCenter] addObserverForName:kUserInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull notification) {
-            if ([ws.target isEqualToString:notification.object]) {
-                ws.userInfo = notification.userInfo[@"userInfo"];
+            NSArray<WFCCUserInfo *> *userInfoList = notification.userInfo[@"userInfoList"];
+            for (WFCCUserInfo *userInfo in userInfoList) {
+                if ([ws.target isEqualToString:userInfo.userId]) {
+                    ws.userInfo = userInfo;
+                    break;
+                }
             }
         }];
         
@@ -62,8 +66,11 @@
 //        self.qrStr = [NSString stringWithFormat:@"wildfirechat://group/%@?from=%@", self.target, [WFCCNetworkService sharedInstance].userId];
         
         [[NSNotificationCenter defaultCenter] addObserverForName:kGroupInfoUpdated object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull notification) {
-            if ([ws.target isEqualToString:notification.object]) {
-                ws.groupInfo = notification.userInfo[@"groupInfo"];
+            NSArray<WFCCGroupInfo *> *groupInfoList = notification.userInfo[@"groupInfoList"];
+            for (WFCCGroupInfo *groupInfo in groupInfoList) {
+                if ([ws.target isEqualToString:groupInfo.target]) {
+                    ws.groupInfo = groupInfo;
+                }
             }
         }];