|
@@ -210,7 +210,9 @@
|
|
|
}
|
|
|
|
|
|
- (void)getFriend{
|
|
|
- [g_server listAttention:50 userId:MY_USER_ID toView:self];
|
|
|
+
|
|
|
+
|
|
|
+ [g_server listAttention:1000 userId:MY_USER_ID toView:self];
|
|
|
// [g_server listFriend:0 userId:MY_USER_ID toView:self];
|
|
|
}
|
|
|
|
|
@@ -240,7 +242,7 @@
|
|
|
if ([g_myself.chatSyncTimeLen longLongValue] == 0 || [g_myself.chatSyncTimeLen longLongValue] == -1) {
|
|
|
syncTimeLen = 0;
|
|
|
}
|
|
|
- [g_default setBool:YES forKey:kISFirstGetLastChatList];
|
|
|
+ // [g_default setBool:YES forKey:kISFirstGetLastChatList];
|
|
|
|
|
|
}else {
|
|
|
syncTimeLen = g_server.lastOfflineTime * 1000.0;
|
|
@@ -268,12 +270,25 @@
|
|
|
//刷新数据
|
|
|
- (void)viewDidAppear:(BOOL)animated{
|
|
|
[super viewDidAppear:animated];
|
|
|
-
|
|
|
+
|
|
|
+ [g_server getCurrentTimeToView:self];
|
|
|
+ if(g_xmpp.isLogined != 1){
|
|
|
+ // 掉线后点击title重连
|
|
|
+ // 判断XMPP是否在线 不在线重连
|
|
|
+ // [g_xmpp showXmppOfflineAlert];
|
|
|
+ [g_xmpp login];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
[self getTotalNewMsgCount];
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+// xmpp掉线后提示
|
|
|
+- (void) showXmppOfflineAlert {
|
|
|
+
|
|
|
+ [g_App showAlert:Localized(@"JX_Reconnect") delegate:self];
|
|
|
+}
|
|
|
//-(void)newRequest:(NSNotification *)notifacation
|
|
|
//{
|
|
|
// [self getFriend];
|
|
@@ -327,24 +342,26 @@
|
|
|
self.view.backgroundColor=kRGBColor250;
|
|
|
[self customView];
|
|
|
[self navGuese];
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
[self getLastChatList];
|
|
|
+
|
|
|
+ upOrDown = 0;
|
|
|
+
|
|
|
+
|
|
|
NSString *msgStr=[g_default objectForKey:@"refushMsgHistoryxxx"];
|
|
|
if (msgStr.length>0) {
|
|
|
|
|
|
}else{
|
|
|
-
|
|
|
-
|
|
|
- [self getAllChatList];
|
|
|
- [self getFriend];
|
|
|
- upOrDown = 0;
|
|
|
+
|
|
|
+ [self getAllChatList];
|
|
|
+ [self getFriend];
|
|
|
|
|
|
[g_default setObject:@"refushMsgHistoryxxx" forKey:@"refushMsgHistoryxxx"];
|
|
|
[g_default synchronize];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- [self getServerData];
|
|
|
+// [self getServerData];
|
|
|
[g_notify addObserver:self selector:@selector(onQuitRoom:) name:kQuitRoomNotifaction object:nil];//退出了房间
|
|
|
|
|
|
// self.tableView.contentInset=UIEdgeInsetsMake(64, 0, 20, 0);
|
|
@@ -487,23 +504,23 @@
|
|
|
};
|
|
|
|
|
|
|
|
|
-
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
-
|
|
|
- NSArray *friends = [[JXFriendObject sharedInstance] fetchAllFriendsFromLocal];
|
|
|
- __block int a=0;
|
|
|
- [friends enumerateObjectsUsingBlock:^(JXFriendObject *_Nonnull friend, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
-
|
|
|
- if ([friend.msgsNew intValue]==1) {
|
|
|
- a++;
|
|
|
- }
|
|
|
-
|
|
|
- }];
|
|
|
-
|
|
|
- [self showNewMsgCount:a];
|
|
|
-
|
|
|
-
|
|
|
- });
|
|
|
+//
|
|
|
+// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+//
|
|
|
+// NSArray *friends = [[JXFriendObject sharedInstance] fetchAllFriendsFromLocal];
|
|
|
+// __block int a=0;
|
|
|
+// [friends enumerateObjectsUsingBlock:^(JXFriendObject *_Nonnull friend, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
+//
|
|
|
+// if ([friend.msgsNew intValue]==1) {
|
|
|
+// a++;
|
|
|
+// }
|
|
|
+//
|
|
|
+// }];
|
|
|
+//
|
|
|
+// [self showNewMsgCount:a];
|
|
|
+//
|
|
|
+//
|
|
|
+// });
|
|
|
|
|
|
}
|
|
|
|
|
@@ -917,7 +934,7 @@
|
|
|
- (void) delAllChatLogNotifi:(NSNotification *)notif {
|
|
|
[self getServerData];
|
|
|
self.msgTotal = 0;
|
|
|
- _strCount=0;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -927,6 +944,35 @@
|
|
|
}
|
|
|
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
|
|
{
|
|
|
+ NSMutableArray *temArr=[NSMutableArray array];;
|
|
|
+ // if (timeSend>currentTime||[obj.user.groupStatus intValue]==1||[userx.fromUserId isEqualToString:@"10000"] || [userx.fromUserId isEqualToString:@"10100"] || [userx.fromUserId isEqualToString:@"10000006"]||[userx.fromUserId isEqualToString:@"10000009"] ) {
|
|
|
+ [_array enumerateObjectsUsingBlock:^(JXMsgAndUserObject *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
+
|
|
|
+ NSTimeInterval timeSend =[obj.message.timeSend timeIntervalSince1970];
|
|
|
+ NSTimeInterval currentTime =[[NSDate date] timeIntervalSince1970];
|
|
|
+
|
|
|
+ JXMessageObject *userx=obj.message;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ NSLog(@"obj.user.userNickname %@ === userx.content %@",obj.user.userNickname,userx.content);
|
|
|
+
|
|
|
+ if ([userx.fromUserId isEqualToString:@"10000"]||timeSend>currentTime ||[obj.user.groupStatus intValue]==2||[obj.user.groupStatus intValue]==1||obj.user.userNickname.length==0||userx.content.length==0||([obj.message.type intValue] == kWCMessageTypeSuperDelete || [obj.message.type intValue] == kWCMessageTypeGroupActivity)) {
|
|
|
+ // [temArr insertObject:obj atIndex:0];
|
|
|
+ [_array removeObjectAtIndex:idx];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ [temArr addObject:obj];
|
|
|
+ }
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+ _array=temArr;
|
|
|
|
|
|
return 1;
|
|
|
}
|
|
@@ -942,9 +988,7 @@
|
|
|
- (void)sendServiecGroupJid:(NSString *)jid{
|
|
|
|
|
|
|
|
|
- [_array enumerateObjectsUsingBlock:^(JXMsgAndUserObject * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
-
|
|
|
- }];
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -1008,21 +1052,21 @@
|
|
|
cell.didDelMsg = @selector(onDelMsg:);
|
|
|
|
|
|
// [cell msgCellDataSet:dict indexPath:indexPath];
|
|
|
- cell.title = dict.user.remarkName.length > 0 ? dict.user.remarkName : dict.user.userNickname;
|
|
|
+ NSString *nickName = dict.user.remarkName.length > 0 ? dict.user.remarkName : dict.user.userNickname;
|
|
|
+
|
|
|
+ cell.title = nickName;
|
|
|
// if ([dict.message.fromUserId isEqualToString:@"10000"]) { cell.lbTitle.text=@"即信"; cell.title=@"即信"; }
|
|
|
|
|
|
cell.user = dict.user;
|
|
|
cell.userId = dict.user.userId;
|
|
|
|
|
|
- if (cell.user.groupType.length) {
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
// cell.bage = [NSString stringWithFormat:@"%d",[dict.user.msgsNew intValue]];
|
|
|
if ([dict.user.offlineNoPushMsg intValue] == 1) {
|
|
|
cell.bage = [NSString stringWithFormat:@"%@",@"0"];
|
|
|
- _strCount = [NSString stringWithFormat:@"%@",@"0"];
|
|
|
+ //_strCount = [NSString stringWithFormat:@"%@",@"0"];
|
|
|
} else {
|
|
|
cell.bage = [NSString stringWithFormat:@"%d",[dict.user.msgsNew intValue]];
|
|
|
}
|
|
@@ -1047,7 +1091,7 @@
|
|
|
cell.headImage=@"ALOGO_1200";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
NSString *lastContet = [dict.message getLastContent];
|
|
|
BOOL flag = NO;
|
|
|
if ([dict.user.isAtMe intValue] == 1 && _seekTextField.text.length <= 0 && (dict.user.roomFlag || dict.user.roomId.length > 0)) {
|
|
@@ -1392,7 +1436,7 @@
|
|
|
|
|
|
//NSLog(@"群聊-单聊 消息 --- %@",[msg mj_keyValues]);
|
|
|
|
|
|
-
|
|
|
+ _array;
|
|
|
[self doRefresh:msg showNumber:showNumber];
|
|
|
msg = nil;
|
|
|
}
|
|
@@ -1522,13 +1566,10 @@
|
|
|
|
|
|
if (newobj.user) {
|
|
|
|
|
|
- NSLog(@"消息ID。%@",msg.messageId);
|
|
|
-
|
|
|
+ // NSLog(@"消息ID。%@",msg.messageId);
|
|
|
if (_topNum>_array.count) {
|
|
|
-
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
[_array insertObject:newobj atIndex:_topNum];
|
|
|
|
|
|
// NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
|
|
@@ -1546,9 +1587,8 @@
|
|
|
}
|
|
|
|
|
|
@try {
|
|
|
- //[_table gotoFirstRow:YES];
|
|
|
-
|
|
|
- // [_table beginUpdates];
|
|
|
+ //[_table gotoFirstRow:YES];
|
|
|
+ // [_table beginUpdates];
|
|
|
//[_table insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
|
|
|
// [_table endUpdates]; //修改了
|
|
|
} @catch (NSException *exception) {
|
|
@@ -1562,13 +1602,17 @@
|
|
|
|
|
|
newobj = nil;
|
|
|
}
|
|
|
+
|
|
|
+ [self getTotalNewMsgCount];
|
|
|
+
|
|
|
if(msg.isMySend || !showNumber || [oldobj.user.offlineNoPushMsg intValue] == 1){
|
|
|
return;
|
|
|
}else{
|
|
|
- [self getTotalNewMsgCount];
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+ // [_table reloadData];
|
|
|
// _reciveNewMessage2222=100;
|
|
|
// JXMessageObject *msgUse=oldobj.message;
|
|
|
// long time = (long)[[NSDate date] timeIntervalSince1970];
|
|
@@ -1596,27 +1640,15 @@
|
|
|
|
|
|
|
|
|
if (p.count>0) {
|
|
|
- [_array addObjectsFromArray:p];
|
|
|
- NSMutableArray *tempArray=[NSMutableArray arrayWithCapacity:0];
|
|
|
- [_array enumerateObjectsUsingBlock:^(JXMsgAndUserObject * obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
- JXMessageObject *userx=obj.message;
|
|
|
- if ([obj.user.groupStatus intValue]==2||[obj.user.groupStatus intValue]==1||[userx.fromUserId isEqualToString:@"10000"] || [userx.fromUserId isEqualToString:@"10100"] || [userx.fromUserId isEqualToString:@"10000006"]||[userx.fromUserId isEqualToString:@"10000009"] || [obj.message.timeSend timeIntervalSince1970]>[[NSDate date] timeIntervalSince1970]) {
|
|
|
-
|
|
|
-
|
|
|
- }else{
|
|
|
-
|
|
|
- [tempArray addObject:obj];
|
|
|
- }
|
|
|
-
|
|
|
- }];
|
|
|
-
|
|
|
- _array = tempArray;
|
|
|
+ _array=p;
|
|
|
+ //_array = tempArray;
|
|
|
|
|
|
//让数组按时间排序
|
|
|
[self sortArrayWithTime];
|
|
|
[_table hideEmptyImage];
|
|
|
[_table reloadData];
|
|
|
self.isShowFooterPull = NO;
|
|
|
+
|
|
|
}else{
|
|
|
|
|
|
[_table showEmptyImage:EmptyTypeNoData];
|
|
@@ -1799,12 +1831,10 @@
|
|
|
NSArray *fromArr=[p.message.fromId componentsSeparatedByString:@"/"];
|
|
|
|
|
|
if ([[fromArr lastObject] intValue]==1||[p.user.status intValue]!=2) {
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
sendView.useInfoTempChat=11;
|
|
|
-
|
|
|
-
|
|
|
- }else{
|
|
|
+ }
|
|
|
+ /* else{
|
|
|
|
|
|
if (fromArr==nil) {
|
|
|
sendView.useInfoTempChat=11;
|
|
@@ -1813,7 +1843,7 @@
|
|
|
|
|
|
sendView.useInfoTempChat=1;
|
|
|
}
|
|
|
- }
|
|
|
+ } */
|
|
|
sendView.rowIndex = indexPath.row;
|
|
|
sendView.lastMsg = p.message;
|
|
|
sendView.chatPerson = p.user;
|
|
@@ -1961,8 +1991,8 @@
|
|
|
case login_status_yes:{
|
|
|
// self.title = Localized(@"JXMsgViewController_OnLine");
|
|
|
// 同步最近一条聊天记录
|
|
|
- // [self getLastChatList];
|
|
|
- //[_activity stopAnimating];
|
|
|
+ [self getLastChatList];
|
|
|
+ [_activity stopAnimating];
|
|
|
}
|
|
|
|
|
|
break;
|
|
@@ -2408,7 +2438,7 @@
|
|
|
|
|
|
-(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
|
|
|
[_wait hide];
|
|
|
-
|
|
|
+ //点击好友头像响应
|
|
|
if ([aDownload.action isEqualToString:act_UserGet]) {
|
|
|
NSString *memberAcc= dict[@"membershipAccount"];
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:memberAcc forKey:@"membershipAccount_ID"];
|
|
@@ -2418,10 +2448,25 @@
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:gradeIndexcc forKey:@"gradeIndexcc"];
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
self.titleLb.text = [NSString stringWithFormat:@"我的即信号:%@",memberAcc];
|
|
|
+
|
|
|
+ JXUserObject* user = [[JXUserObject alloc]init];
|
|
|
+
|
|
|
+ // _titleLb.text=[NSString stringWithFormat:@"我的即信号%@",g_server.myself.userId];
|
|
|
+
|
|
|
+ [user getDataFromDict:dict];
|
|
|
+ [user updateUserType];
|
|
|
+ [g_notify postNotificationName:kFriendListRefresh object:nil];
|
|
|
+
|
|
|
+ // JXUserInfoVC* vc = [JXUserInfoVC alloc];
|
|
|
+ // vc.user = user;
|
|
|
+ // vc = [vc init];
|
|
|
+ //// [g_window addSubview:vc.view];
|
|
|
+ // [g_navigation pushViewController:vc animated:YES];
|
|
|
+ // [self cancelBtnAction];
|
|
|
}
|
|
|
|
|
|
//更新本地好友
|
|
|
- if ([aDownload.action isEqualToString:act_AttentionList]) {
|
|
|
+ if ([aDownload.action isEqualToString:act_AttentionList]) {
|
|
|
[_wait stop];
|
|
|
[self stopLoading];
|
|
|
JXProgressVC * pv = [JXProgressVC alloc];
|
|
@@ -2432,14 +2477,11 @@
|
|
|
|
|
|
//访问DB获取好友消息列表
|
|
|
// NSMutableArray* p = [[JXMessageObject sharedInstance] fetchRecentChat];
|
|
|
- //[self getServerData];
|
|
|
- // [self getLastChatList];
|
|
|
+ [self getServerData];
|
|
|
+ // [self getLastChatList];
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
if( [aDownload.action isEqualToString:act_roomAdd] ){
|
|
|
|
|
|
_chatRoom = [[JXXMPP sharedInstance].roomPool createRoom:_room.roomJid title:_room.name];
|
|
@@ -2465,7 +2507,7 @@
|
|
|
}
|
|
|
|
|
|
//获取弹窗广告响应
|
|
|
- if( [aDownload.action isEqualToString:act_getAdvertising] ){
|
|
|
+ if( [aDownload.action isEqualToString:act_getAdvertising] ){
|
|
|
if (dict) {
|
|
|
NSArray *buttons = nil;
|
|
|
NSString *link = dict[@"link"];
|
|
@@ -2519,25 +2561,6 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //点击好友头像响应
|
|
|
- if( [aDownload.action isEqualToString:act_UserGet] ){
|
|
|
- JXUserObject* user = [[JXUserObject alloc]init];
|
|
|
-
|
|
|
-
|
|
|
- // _titleLb.text=[NSString stringWithFormat:@"我的即信号%@",g_server.myself.userId];
|
|
|
-
|
|
|
- [user getDataFromDict:dict];
|
|
|
- [user updateUserType];
|
|
|
- [g_notify postNotificationName:kFriendListRefresh object:nil];
|
|
|
-
|
|
|
-// JXUserInfoVC* vc = [JXUserInfoVC alloc];
|
|
|
-// vc.user = user;
|
|
|
-// vc = [vc init];
|
|
|
-//// [g_window addSubview:vc.view];
|
|
|
-// [g_navigation pushViewController:vc animated:YES];
|
|
|
-// [self cancelBtnAction];
|
|
|
- }
|
|
|
-
|
|
|
if( [aDownload.action isEqualToString:act_roomGet] ){
|
|
|
|
|
|
JXUserObject* user = [[JXUserObject alloc]init];
|
|
@@ -2562,7 +2585,9 @@
|
|
|
|
|
|
if (![dict objectForKey:@"member"]) {
|
|
|
[g_server showMsg:Localized(@"JX_YouOutOfGroup")];
|
|
|
-
|
|
|
+ self.groupStatus = [NSNumber numberWithInt:1];
|
|
|
+ _chatPerson.groupStatus = [NSNumber numberWithInt:1];
|
|
|
+ [_chatPerson updateGroupInvalid];
|
|
|
}else {
|
|
|
int talkTime = [[dict objectForKey:@"talkTime"] intValue];
|
|
|
int role = [[(NSDictionary *)[dict objectForKey:@"member"] objectForKey:@"role"] intValue];
|
|
@@ -2632,7 +2657,7 @@
|
|
|
user.createUserId = [dict objectForKey:@"userId"];
|
|
|
user.timeCreate = [NSDate dateWithTimeIntervalSince1970:[[dict objectForKey:@"createTime"] longLongValue]];
|
|
|
user.isNeedVerify = [dict objectForKey:@"isNeedVerify"];
|
|
|
- /*
|
|
|
+ /**/
|
|
|
|
|
|
if (![dict objectForKey:@"member"]) {
|
|
|
user.groupStatus = [NSNumber numberWithInt:1];
|
|
@@ -2643,7 +2668,7 @@
|
|
|
user.groupStatus = [NSNumber numberWithInt:2];
|
|
|
[user updateGroupInvalid];
|
|
|
}
|
|
|
- */
|
|
|
+
|
|
|
if([[dict allKeys] containsObject:@"groupType"]) {
|
|
|
NSDictionary *dictby=[dict objectForKey:@"groupType"];
|
|
|
|
|
@@ -2667,6 +2692,8 @@
|
|
|
[[JXXMPP sharedInstance].roomPool joinRoom:user.userId title:user.userNickname lastDate:nil isNew:YES];
|
|
|
}
|
|
|
|
|
|
+ NSLog(@"%@",_room.roomId);
|
|
|
+
|
|
|
if (![user haveTheUser]){
|
|
|
[user insertRoom];
|
|
|
|
|
@@ -2682,55 +2709,55 @@
|
|
|
|
|
|
// [tempArray addObject:user];
|
|
|
} //群头衔的设置
|
|
|
- /*-------------------*/
|
|
|
+
|
|
|
|
|
|
if ([[dict objectForKey:@"jid"] intValue] > 0 && !_isGetLastMsgList) {
|
|
|
- // 获取最近一条记录
|
|
|
- NSArray *arr = [[JXMessageObject sharedInstance] fetchMessageListWithUser:[dict objectForKey:@"jid"] byAllNum:0 pageCount:20 startTime:[NSDate dateWithTimeIntervalSince1970:0]];
|
|
|
-
|
|
|
- // 去除
|
|
|
- JXMessageObject *lastMsg = arr.lastObject;
|
|
|
- if (!lastMsg) {
|
|
|
- lastMsg = arr.firstObject;
|
|
|
- }
|
|
|
- JXUserObject *user = [[JXUserObject sharedInstance] getUserById:dict[@"jid"]];
|
|
|
- NSMutableDictionary *taskDic = [NSMutableDictionary dictionary];
|
|
|
- [taskDic setObject:[dict objectForKey:@"jid"] forKey:@"userId"];
|
|
|
- [taskDic setObject:[NSDate dateWithTimeIntervalSince1970:[dict[@"timeSend"] longLongValue]] forKey:@"lastTime"];
|
|
|
- if (lastMsg) {
|
|
|
- [taskDic setObject:lastMsg.timeSend forKey:@"startTime"];
|
|
|
- if (lastMsg.messageId) {
|
|
|
- [taskDic setObject:lastMsg.messageId forKey:@"startMsgId"];
|
|
|
- }
|
|
|
- }
|
|
|
- if (user.roomId) {
|
|
|
- [taskDic setObject:user.roomId forKey:@"roomId"];
|
|
|
- }
|
|
|
- if ([g_myself.chatSyncTimeLen longLongValue] != -2) {
|
|
|
-
|
|
|
- [self createSynTask:taskDic];
|
|
|
-
|
|
|
- [_taskArray addObject:taskDic];
|
|
|
- }
|
|
|
-
|
|
|
- long value = (long)([lastMsg.timeSend timeIntervalSince1970]*1000);
|
|
|
- if (!lastMsg) {
|
|
|
- // 没有最后一条消息的记录就拉取一周前的数据
|
|
|
- value = (long)(g_server.lastOfflineTime*1000);//-(7*24*3600*1000);
|
|
|
- }
|
|
|
-
|
|
|
- NSString *listStr = [NSString stringWithFormat:@"%@,%ld",dict[@"jid"],value];
|
|
|
- [listArr addObject:listStr];
|
|
|
- }
|
|
|
+ // 获取最近一条记录
|
|
|
+ NSArray *arr = [[JXMessageObject sharedInstance] fetchMessageListWithUser:[dict objectForKey:@"jid"] byAllNum:0 pageCount:20 startTime:[NSDate dateWithTimeIntervalSince1970:0]];
|
|
|
+
|
|
|
+ // 去除
|
|
|
+ JXMessageObject *lastMsg = arr.lastObject;
|
|
|
+ if (!lastMsg) {
|
|
|
+ lastMsg = arr.firstObject;
|
|
|
+ }
|
|
|
+ JXUserObject *user = [[JXUserObject sharedInstance] getUserById:dict[@"jid"]];
|
|
|
+ NSMutableDictionary *taskDic = [NSMutableDictionary dictionary];
|
|
|
+ [taskDic setObject:[dict objectForKey:@"jid"] forKey:@"userId"];
|
|
|
+ [taskDic setObject:[NSDate dateWithTimeIntervalSince1970:[dict[@"timeSend"] longLongValue]] forKey:@"lastTime"];
|
|
|
+ if (lastMsg) {
|
|
|
+ [taskDic setObject:lastMsg.timeSend forKey:@"startTime"];
|
|
|
+ if (lastMsg.messageId) {
|
|
|
+ [taskDic setObject:lastMsg.messageId forKey:@"startMsgId"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (user.roomId) {
|
|
|
+ [taskDic setObject:user.roomId forKey:@"roomId"];
|
|
|
+ }
|
|
|
+ if ([g_myself.chatSyncTimeLen longLongValue] != -2) {
|
|
|
+
|
|
|
+ [self createSynTask:taskDic];
|
|
|
+
|
|
|
+ [_taskArray addObject:taskDic];
|
|
|
+ }
|
|
|
+
|
|
|
+ long value = (long)([lastMsg.timeSend timeIntervalSince1970]*1000);
|
|
|
+ if (!lastMsg) {
|
|
|
+ // 没有最后一条消息的记录就拉取一周前的数据
|
|
|
+ value = (long)(g_server.lastOfflineTime*1000);//-(7*24*3600*1000);
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *listStr = [NSString stringWithFormat:@"%@,%ld",dict[@"jid"],value];
|
|
|
+ [listArr addObject:listStr];
|
|
|
+ }
|
|
|
if (listArr.count > 0) {
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
- // 如果最近一条信息接口没有获取到,批量拉取消息
|
|
|
- if (!_isGetLastMsgList) {
|
|
|
- [g_xmpp pullBatchGroupMessageReqWithJidListArray:listArr];
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // [_table reloadData];
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ // 如果最近一条信息接口没有获取到,批量拉取消息
|
|
|
+ if (!_isGetLastMsgList) {
|
|
|
+ [g_xmpp pullBatchGroupMessageReqWithJidListArray:listArr];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ [_table reloadData];
|
|
|
}
|
|
|
|
|
|
#pragma mark --- 获取最后个人消息列表 act_tigaseGetLastChatList
|
|
@@ -2740,15 +2767,18 @@
|
|
|
_isGetLastMsgList = YES;
|
|
|
[g_default setBool:YES forKey:kISFirstGetLastChatList];
|
|
|
if ([g_myself.chatSyncTimeLen longLongValue] != -2) {
|
|
|
- [[JXUserObject sharedInstance] updateUserLastChatList:array1];
|
|
|
- if (array1.count > 0) {
|
|
|
- [self getServerData];
|
|
|
+
|
|
|
+ if (array1.count==0) {
|
|
|
+ }else{
|
|
|
+ [[JXUserObject sharedInstance] updateUserLastChatList:array1];
|
|
|
}
|
|
|
+
|
|
|
+ [self getServerData];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-// [array1 enumerateObjectsUsingBlock:^(NSDictionary * obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
-// NSLog(@"---- 个人信息列表 xxxxx%@ %@",[obj objectForKey:@"toUserName"] , [obj objectForKey:@"fromUserName"] );
|
|
|
-// }];
|
|
|
+ //[array1 enumerateObjectsUsingBlock:^(NSDictionary * obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
+ // NSLog(@"---- 个人信息列表 xxxxx%@ %@",[obj objectForKey:@"toUserName"] , [obj objectForKey:@"fromUserName"] ); }];
|
|
|
|
|
|
[_taskArray removeAllObjects];
|
|
|
NSMutableArray *listArr = [NSMutableArray array];
|
|
@@ -2919,6 +2949,7 @@
|
|
|
_isGetLastMsgList = NO;
|
|
|
[self.header endRefreshing];
|
|
|
[self getAllChatList];
|
|
|
+ [self getAllChatList];
|
|
|
//[self getFriend];
|
|
|
// [g_xmpp.roomPool createAll];
|
|
|
}
|