|
@@ -155,7 +155,8 @@
|
|
|
_indexNums=0;
|
|
|
_isGetLastMsgList = NO;
|
|
|
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
- // [g_notify addObserver:self selector:@selector(newFriend:) name:kXMPPNewFriendNotifaction object:nil];
|
|
|
+ //kChatViewDisappear
|
|
|
+ // [g_notify addObserver:self selector:@selector(newFriend:) name:kXMPPNewFriendNotifaction object:nil];
|
|
|
|
|
|
[g_notify addObserver:self selector:@selector(newRequest:) name:kXMPPNewRequestNotifaction object:nil];
|
|
|
[g_notify addObserver:self selector:@selector(showAD) name:kLaunchAdShowFinishNotifaction object:nil];
|
|
@@ -212,56 +213,63 @@
|
|
|
- (void)getFriend{
|
|
|
|
|
|
|
|
|
- [g_server listAttention:1000 userId:MY_USER_ID toView:self];
|
|
|
+ [g_server listAttention:0 userId:MY_USER_ID toView:self];
|
|
|
// [g_server listFriend:0 userId:MY_USER_ID toView:self];
|
|
|
}
|
|
|
|
|
|
-//获取所有的群
|
|
|
+#pragma mark --- 获取所有的群
|
|
|
- (void)getAllChatList {
|
|
|
+ // [g_server listAttention:50 userId:MY_USER_ID toView:self];
|
|
|
// [g_server listRoom:_page roomName:nil toView:self];
|
|
|
- [g_server listHisRoom:_page pageSize:1000 toView:self];
|
|
|
+ [g_server listHisRoom:0 pageSize:1000 toView:self];
|
|
|
}
|
|
|
|
|
|
-//获取所有的料天信息列表
|
|
|
+#pragma mark -- 获取所有的料天信息列表
|
|
|
- (void)getLastChatList {
|
|
|
|
|
|
BOOL isFirstSync = [g_default boolForKey:kISFirstGetLastChatList];
|
|
|
|
|
|
long long syncTimeLen;
|
|
|
|
|
|
-
|
|
|
if (!isFirstSync) {
|
|
|
//if ([g_myself.chatSyncTimeLen longLongValue] > [g_myself.groupChatSyncTimeLen longLongValue]) {
|
|
|
- syncTimeLen = [g_myself.chatSyncTimeLen longLongValue];
|
|
|
+ syncTimeLen =[g_myself.chatSyncTimeLen longLongValue];
|
|
|
//}else {
|
|
|
//syncTimeLen = [g_myself.groupChatSyncTimeLen longLongValue];
|
|
|
//}
|
|
|
- syncTimeLen = syncTimeLen * 24 * 3600 * 1000;
|
|
|
-// syncTimeLen = [[NSDate date] timeIntervalSince1970] * 1000.0 - m;
|
|
|
- // 同步 永久 syncTime == 0
|
|
|
- if ([g_myself.chatSyncTimeLen longLongValue] == 0 || [g_myself.chatSyncTimeLen longLongValue] == -1) {
|
|
|
- syncTimeLen = 0;
|
|
|
- }
|
|
|
- // [g_default setBool:YES forKey:kISFirstGetLastChatList];
|
|
|
+ NSDate *datenow = [NSDate date];
|
|
|
+ long long timeSp = (long)([datenow timeIntervalSince1970]*1000);
|
|
|
+ syncTimeLen = syncTimeLen * 24 * 3600 * 1000;
|
|
|
+ syncTimeLen=timeSp-syncTimeLen;
|
|
|
|
|
|
+ //syncTimeLen = [[NSDate date] timeIntervalSince1970] * 1000.0 - m;
|
|
|
+ // 同步 永久 syncTime == 0
|
|
|
+ if ([g_myself.chatSyncTimeLen longLongValue] == 0 || [g_myself.chatSyncTimeLen longLongValue] == -1) {
|
|
|
+
|
|
|
+ syncTimeLen = 0;
|
|
|
+
|
|
|
+ NSLog(@"最后一次离线时间 - 2 :%f",g_server.lastOfflineTime);
|
|
|
+ }
|
|
|
+
|
|
|
}else {
|
|
|
- syncTimeLen = g_server.lastOfflineTime * 1000.0;
|
|
|
+
|
|
|
+ syncTimeLen =g_server.lastOfflineTime * 1000.0;
|
|
|
|
|
|
// syncTimeLen =604800000;
|
|
|
NSLog(@"最后一次离线时间:%f",g_server.lastOfflineTime);
|
|
|
}
|
|
|
// 不同步 batchJoinMucChat();
|
|
|
-
|
|
|
- if ([g_myself.chatSyncTimeLen longLongValue] == -2) {
|
|
|
-
|
|
|
- [g_xmpp.roomPool createAll];
|
|
|
-
|
|
|
- }else {
|
|
|
-
|
|
|
-
|
|
|
+ //NSTimeInterval interval = syncTimeLen;
|
|
|
+ //NSInteger time = round(syncTimeLen);
|
|
|
+
|
|
|
+// if ([g_myself.chatSyncTimeLen longLongValue] == -2) {
|
|
|
+//
|
|
|
+// [g_xmpp.roomPool createAll];
|
|
|
+//
|
|
|
+// }else {
|
|
|
+
|
|
|
[g_server getLastChatListStartTime:[NSNumber numberWithLong:syncTimeLen] toView:self];
|
|
|
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -270,8 +278,8 @@
|
|
|
//刷新数据
|
|
|
- (void)viewDidAppear:(BOOL)animated{
|
|
|
[super viewDidAppear:animated];
|
|
|
-
|
|
|
- [g_server getCurrentTimeToView:self];
|
|
|
+
|
|
|
+
|
|
|
if(g_xmpp.isLogined != 1){
|
|
|
// 掉线后点击title重连
|
|
|
// 判断XMPP是否在线 不在线重连
|
|
@@ -342,8 +350,9 @@
|
|
|
self.view.backgroundColor=kRGBColor250;
|
|
|
[self customView];
|
|
|
[self navGuese];
|
|
|
-
|
|
|
- [self getLastChatList];
|
|
|
+
|
|
|
+ [self getServerData];
|
|
|
+
|
|
|
|
|
|
upOrDown = 0;
|
|
|
|
|
@@ -352,9 +361,10 @@
|
|
|
if (msgStr.length>0) {
|
|
|
|
|
|
}else{
|
|
|
-
|
|
|
- [self getAllChatList];
|
|
|
- [self getFriend];
|
|
|
+ [self getLastChatList];
|
|
|
+ [g_server listAttention:0 userId:MY_USER_ID toView:self];
|
|
|
+ [self getAllChatList];
|
|
|
+ //[self getFriend];
|
|
|
|
|
|
[g_default setObject:@"refushMsgHistoryxxx" forKey:@"refushMsgHistoryxxx"];
|
|
|
[g_default synchronize];
|
|
@@ -642,20 +652,19 @@
|
|
|
|
|
|
// 更改备注名
|
|
|
- (void)friendRemarkNotif:(NSNotification *)notif {
|
|
|
+
|
|
|
+// _array = [[JXMessageObject sharedInstance] fetchRecentChat];
|
|
|
+// [_table reloadData];
|
|
|
+ JXUserObject *user = notif.object;
|
|
|
|
|
|
-// [self getLastChatList];
|
|
|
- _array = [[JXMessageObject sharedInstance] fetchRecentChat];
|
|
|
- [_table reloadData];
|
|
|
-// JXUserObject *user = notif.object;
|
|
|
-
|
|
|
-// for (int i = 0; i < _array.count; i ++) {
|
|
|
-// JXMsgAndUserObject *obj = _array[i];
|
|
|
-// if ([obj.user.userId isEqualToString:user.userId]) {
|
|
|
-// obj.user.remarkName = user.remarkName;
|
|
|
-//// [_table reloadRow:i section:0];
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
+ for (int i = 0; i < _array.count; i ++) {
|
|
|
+ JXMsgAndUserObject *obj = _array[i];
|
|
|
+ if ([obj.user.userId isEqualToString:user.userId]) {
|
|
|
+ obj.user.remarkName = user.remarkName;
|
|
|
+ [_table reloadRow:i section:0];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 消息撤回
|
|
@@ -950,7 +959,6 @@
|
|
|
|
|
|
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);
|
|
|
|
|
@@ -1159,12 +1167,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
-/**现实新朋友的角标*/
|
|
|
-- (void) showNewMsgCount:(NSInteger)friendNewMsgNum {
|
|
|
-
|
|
|
- _strCount=[NSString stringWithFormat:@"%zd",friendNewMsgNum];
|
|
|
|
|
|
-}
|
|
|
|
|
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
|
|
_reciveNewMessage2222=100;
|
|
@@ -1183,15 +1186,14 @@
|
|
|
{
|
|
|
|
|
|
// 判断是否为加好友或者删除好友
|
|
|
- JXFriendObject * friend = (JXFriendObject*) notifacation.object;
|
|
|
+ //JXFriendObject * friend = (JXFriendObject*) notifacation.object;
|
|
|
|
|
|
//self.countTipL.hidden=NO;
|
|
|
JXMessageObject *msg = notifacation.object;
|
|
|
NSNumber *bodyType = msg.type;
|
|
|
|
|
|
- if (bodyType.intValue == kRoomRemind_DelMember || bodyType.intValue == kRoomRemind_AddMember) { //|| bodyType.intValue == 1
|
|
|
-
|
|
|
- [self getFriend];
|
|
|
+ if (bodyType.intValue == kRoomRemind_DelMember || bodyType.intValue == kRoomRemind_AddMember) { //|| bodyType.intValue ==
|
|
|
+ [self getFriend];
|
|
|
}
|
|
|
|
|
|
if ([msg.fromUserId isEqualToString:@"10000"]) {
|
|
@@ -1432,7 +1434,7 @@
|
|
|
|
|
|
//NSLog(@"群聊-单聊 消息 --- %@",[msg mj_keyValues]);
|
|
|
|
|
|
- _array;
|
|
|
+ //_array;
|
|
|
[self doRefresh:msg showNumber:showNumber];
|
|
|
msg = nil;
|
|
|
}
|
|
@@ -1468,7 +1470,7 @@
|
|
|
|
|
|
-(void)newRequest:(NSNotification *)notifacation
|
|
|
{
|
|
|
- //[g_server listAttention:0 userId:MY_USER_ID toView:self];
|
|
|
+
|
|
|
JXFriendObject * friend = (JXFriendObject*) notifacation.object;
|
|
|
|
|
|
if (friend.status.intValue==2) {
|
|
@@ -1599,13 +1601,11 @@
|
|
|
newobj = nil;
|
|
|
}
|
|
|
|
|
|
- [self getTotalNewMsgCount];
|
|
|
|
|
|
- if(msg.isMySend || !showNumber || [oldobj.user.offlineNoPushMsg intValue] == 1){
|
|
|
+ if(msg.isMySend || !showNumber || [oldobj.user.offlineNoPushMsg intValue] == 1)
|
|
|
return;
|
|
|
- }else{
|
|
|
-
|
|
|
- }
|
|
|
+ else
|
|
|
+ [self getTotalNewMsgCount];
|
|
|
|
|
|
|
|
|
// [_table reloadData];
|
|
@@ -1653,9 +1653,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
-// [self getTotalNewMsgCount];
|
|
|
+ [self getTotalNewMsgCount];
|
|
|
|
|
|
- //[p removeAllObjects];
|
|
|
+ [p removeAllObjects];
|
|
|
|
|
|
|
|
|
|
|
@@ -1718,12 +1718,10 @@
|
|
|
{
|
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
|
|
|
|
-
|
|
|
- NSLog(@"didselectRowAtIndexPath %@",[[[[self superclass] superclass] superclass] class]);
|
|
|
-
|
|
|
+
|
|
|
[g_notify postNotificationName:@"hiddenTip" object:nil];
|
|
|
|
|
|
- //[self doneBtnAction:self.doneBtn];
|
|
|
+ [self doneBtnAction:self.doneBtn];
|
|
|
|
|
|
JXCell* cell = (JXCell*)[tableView cellForRowAtIndexPath:indexPath];
|
|
|
|
|
@@ -1823,13 +1821,10 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
NSArray *fromArr=[p.message.fromId componentsSeparatedByString:@"/"];
|
|
|
-
|
|
|
- if ([[fromArr lastObject] intValue]==1||[p.user.status intValue]!=2) {
|
|
|
-
|
|
|
- sendView.useInfoTempChat=11;
|
|
|
- }
|
|
|
+ if ([p.message.type intValue]== kWCChatTypeChat &&[[fromArr lastObject] intValue]==1&[p.user.status intValue]!=2) {
|
|
|
+ sendView.useInfoTempChat=11;
|
|
|
+ }
|
|
|
/* else{
|
|
|
|
|
|
if (fromArr==nil) {
|
|
@@ -2400,7 +2395,7 @@
|
|
|
- (void)chatViewDisappear:(NSNotification *)notif{
|
|
|
// [_table reloadData];
|
|
|
// [self getTotalNewMsgCount];
|
|
|
- // [self getServerData];
|
|
|
+ [self getServerData];
|
|
|
}
|
|
|
|
|
|
-(void)logoutNotifi:(NSNotification *)notif{
|
|
@@ -2443,15 +2438,11 @@
|
|
|
NSString *gradeIndexcc= dict[@"gradeIndex"];
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:gradeIndexcc forKey:@"gradeIndexcc"];
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
- self.titleLb.text = [NSString stringWithFormat:@"我的即信号:%@",memberAcc];
|
|
|
-
|
|
|
+ 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];
|
|
|
+ //[g_notify postNotificationName:kFriendListRefresh object:nil];
|
|
|
|
|
|
// JXUserInfoVC* vc = [JXUserInfoVC alloc];
|
|
|
// vc.user = user;
|
|
@@ -2470,11 +2461,11 @@
|
|
|
pv.dbFriends = (long)[_array count] - 1;
|
|
|
pv.dataArray = array1;
|
|
|
pv = [pv init];
|
|
|
-
|
|
|
- //访问DB获取好友消息列表
|
|
|
- // NSMutableArray* p = [[JXMessageObject sharedInstance] fetchRecentChat];
|
|
|
- [self getServerData];
|
|
|
- // [self getLastChatList];
|
|
|
+ //if (array1.count > 300) {
|
|
|
+ /// [g_navigation pushViewController:pv animated:YES];
|
|
|
+ // }
|
|
|
+ // [self.view addSubview:pv.view];
|
|
|
+ //访问DB获取好友消息列表
|
|
|
|
|
|
}
|
|
|
|
|
@@ -2630,6 +2621,7 @@
|
|
|
// [[JXXMPP sharedInstance].roomPool joinRoom:tempDict[@"jid"] title:tempDict[@"name"] lastDate:nil isNew:NO];
|
|
|
// 如果最近一条信息接口没有获取到,就更新
|
|
|
|
|
|
+
|
|
|
/*-------------------*/
|
|
|
for (int i = 0; i < [array1 count]; i++) {
|
|
|
NSDictionary *dict=array1[i];
|
|
@@ -2655,15 +2647,11 @@
|
|
|
user.isNeedVerify = [dict objectForKey:@"isNeedVerify"];
|
|
|
/**/
|
|
|
|
|
|
- if (![dict objectForKey:@"member"]) {
|
|
|
- user.groupStatus = [NSNumber numberWithInt:1];
|
|
|
- [user updateGroupInvalid];
|
|
|
- }
|
|
|
- if (![dict objectForKey:@"jid"]) {
|
|
|
-
|
|
|
- user.groupStatus = [NSNumber numberWithInt:2];
|
|
|
- [user updateGroupInvalid];
|
|
|
+ if ([user.groupStatus intValue]==1||[user.groupStatus intValue]==2) {
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+ // NSLog(@"user.groupStatus intValue = %d",[user.groupStatus intValue]);
|
|
|
|
|
|
if([[dict allKeys] containsObject:@"groupType"]) {
|
|
|
NSDictionary *dictby=[dict objectForKey:@"groupType"];
|
|
@@ -2688,72 +2676,81 @@
|
|
|
[[JXXMPP sharedInstance].roomPool joinRoom:user.userId title:user.userNickname lastDate:nil isNew:YES];
|
|
|
}
|
|
|
|
|
|
- NSLog(@"%@",_room.roomId);
|
|
|
+ //NSLog(@"%@",_room.roomId);
|
|
|
|
|
|
if (![user haveTheUser]){
|
|
|
[user insertRoom];
|
|
|
|
|
|
}else {
|
|
|
[user updateUserNickname];
|
|
|
- // [user update];
|
|
|
+ // [user update];
|
|
|
// 只更新groupType
|
|
|
[user updateGroupType];
|
|
|
- [user updateRoomId];
|
|
|
+ // [user updateRoomId];
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+// if (![dict objectForKey:@"member"]) {
|
|
|
+// // user.groupStatus = [NSNumber numberWithInt:1];
|
|
|
+// //[user updateGroupInvalid];
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// if (![dict objectForKey:@"jid"]) {
|
|
|
+//
|
|
|
+// // user.groupStatus = [NSNumber numberWithInt:2];
|
|
|
+// // [user updateGroupInvalid];
|
|
|
+// return;
|
|
|
+// }
|
|
|
|
|
|
// [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];
|
|
|
- }
|
|
|
- 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];
|
|
|
+
|
|
|
+ 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];
|
|
|
+ }
|
|
|
+ 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];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
#pragma mark --- 获取最后个人消息列表 act_tigaseGetLastChatList
|
|
@@ -2762,82 +2759,24 @@
|
|
|
[self.header endRefreshing];
|
|
|
_isGetLastMsgList = YES;
|
|
|
[g_default setBool:YES forKey:kISFirstGetLastChatList];
|
|
|
+
|
|
|
if ([g_myself.chatSyncTimeLen longLongValue] != -2) {
|
|
|
-
|
|
|
- if (array1.count==0) {
|
|
|
- }else{
|
|
|
- [[JXUserObject sharedInstance] updateUserLastChatList:array1];
|
|
|
+ [[JXUserObject sharedInstance] updateUserLastChatList:array1];
|
|
|
+ if (array1.count > 0) {
|
|
|
+ [self getServerData];
|
|
|
}
|
|
|
-
|
|
|
- [self getServerData];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //[array1 enumerateObjectsUsingBlock:^(NSDictionary * obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
- // NSLog(@"---- 个人信息列表 xxxxx%@ %@",[obj objectForKey:@"toUserName"] , [obj objectForKey:@"fromUserName"] ); }];
|
|
|
+ }
|
|
|
+ if ([g_myself.chatSyncTimeLen longLongValue]== -2) {
|
|
|
+ [_taskArray removeAllObjects];
|
|
|
+ // 获取到群组本地最后一条消息
|
|
|
+ [self getAllChatList];
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- [_taskArray removeAllObjects];
|
|
|
- NSMutableArray *listArr = [NSMutableArray array];
|
|
|
- // 获取到群组本地最后一条消息
|
|
|
- for (NSInteger i = 0; i < array1.count; i ++) {
|
|
|
- NSDictionary *dict = array1[i];
|
|
|
- if ([[dict objectForKey:@"isRoom"] intValue] == 1) {
|
|
|
- // 获取最近一条记录
|
|
|
- NSArray *arr = [[JXMessageObject sharedInstance] fetchMessageListWithUser:[dict objectForKey:@"jid"] byAllNum:0 pageCount:20 startTime:[NSDate dateWithTimeIntervalSince1970:0]];
|
|
|
- // 去除
|
|
|
- JXMessageObject *lastMsg = arr.lastObject;
|
|
|
-// lastMsg.content
|
|
|
-// for (NSInteger i = arr.count - 1; i > 0; i --) {
|
|
|
-// JXMessageObject *firstMsg = arr[i];
|
|
|
-// if ([firstMsg.type integerValue] != kWCMessageTypeRemind) {
|
|
|
-// lastMsg = firstMsg;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
- if (!lastMsg) {
|
|
|
-// continue;
|
|
|
- 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];
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ [_taskArray removeAllObjects];
|
|
|
+ [self act_tigaseGetLastChatListMsg:array1];
|
|
|
|
|
|
- if (listArr.count > 0) {
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
- [g_xmpp pullBatchGroupMessageReqWithJidListArray:listArr];
|
|
|
- });
|
|
|
- }
|
|
|
- // [self getAllChatList];
|
|
|
- // [self getFriend];
|
|
|
- // [g_xmpp.roomPool createAll];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if ([aDownload.action isEqualToString:act_customerLinkList]) {
|
|
@@ -2937,7 +2876,67 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 获取到群组本地最后一条消息
|
|
|
+- (void)act_tigaseGetLastChatListMsg:(NSArray *)array1{
|
|
|
|
|
|
+ NSMutableArray *listArr = [NSMutableArray array];
|
|
|
+ for (NSInteger i = 0; i < array1.count; i ++) {
|
|
|
+ NSDictionary *dict = array1[i];
|
|
|
+ if ([[dict objectForKey:@"isRoom"] intValue] == 1) {
|
|
|
+ // 获取最近一条记录
|
|
|
+ NSArray *arr = [[JXMessageObject sharedInstance] fetchMessageListWithUser:[dict objectForKey:@"jid"] byAllNum:0 pageCount:20 startTime:[NSDate dateWithTimeIntervalSince1970:0]];
|
|
|
+ JXMessageObject *lastMsg = arr.lastObject;
|
|
|
+ // for (NSInteger i = arr.count - 1; i > 0; i --) {
|
|
|
+ // JXMessageObject *firstMsg = arr[i];
|
|
|
+ // if ([firstMsg.type integerValue] != kWCMessageTypeRemind) {
|
|
|
+ // lastMsg = firstMsg;
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ if (!lastMsg) {
|
|
|
+ // continue;
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *listStr = [NSString stringWithFormat:@"%@,%ld",dict[@"jid"],value];
|
|
|
+ [listArr addObject:listStr];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (listArr.count > 0) {
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [g_xmpp pullBatchGroupMessageReqWithJidListArray:listArr];
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
-(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
|
|
|
[_wait hide];
|
|
|
|
|
@@ -2945,14 +2944,14 @@
|
|
|
_isGetLastMsgList = NO;
|
|
|
[self.header endRefreshing];
|
|
|
[self getAllChatList];
|
|
|
- [self getAllChatList];
|
|
|
//[self getFriend];
|
|
|
-// [g_xmpp.roomPool createAll];
|
|
|
+ // [g_xmpp.roomPool createAll];
|
|
|
}
|
|
|
- if ([aDownload.action isEqualToString:act_getGroupOneType]) {
|
|
|
- [_table reloadData];
|
|
|
- }
|
|
|
-
|
|
|
+ if ([aDownload.action isEqualToString:act_getGroupOneType]) {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// if (![aDownload.action isEqualToString:act_userChangeMsgNum] && ![aDownload.action isEqualToString:act_tigaseGetLastChatList]) {
|
|
|
// return show_error;
|
|
|
// }
|
|
@@ -2969,12 +2968,11 @@
|
|
|
*/
|
|
|
if ([aDownload.action isEqualToString:act_tigaseGetLastChatList]) {
|
|
|
|
|
|
- [self getAllChatList];
|
|
|
return show_error;
|
|
|
}
|
|
|
if ([aDownload.action isEqualToString:act_roomListHis]) {
|
|
|
-
|
|
|
- [g_server listHisRoom:_page pageSize:1000 toView:self];
|
|
|
+
|
|
|
+ [self getAllChatList];
|
|
|
|
|
|
}
|
|
|
return hide_error;
|
|
@@ -3083,9 +3081,7 @@
|
|
|
}
|
|
|
|
|
|
if([p.type intValue] == kRoomRemind_AddMember){
|
|
|
-
|
|
|
-// [self getAllChatList];
|
|
|
-
|
|
|
+
|
|
|
if([p.toUserId isEqualToString:MY_USER_ID] || IS_OTHER_DEVICE(p.toUserId)){
|
|
|
if(![g_xmpp.roomPool getRoom:p.objectId]){
|
|
|
JXUserObject* user = [[JXUserObject alloc]init];
|
|
@@ -3554,3 +3550,10 @@
|
|
|
|
|
|
|
|
|
@end
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|