|
|
@@ -291,14 +291,11 @@ static const CGFloat kQuoteViewHeight = 46.0f;
|
|
|
-(void)viewDidAppear:(BOOL)animated{
|
|
|
[super viewDidAppear:animated];
|
|
|
_titlelb.text = self.titlename;
|
|
|
- [self startTimer];
|
|
|
-// NSLog(@"viewDidAppear-----:%@",self);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-(void)viewWillDisappear:(BOOL)animated{
|
|
|
[super viewWillDisappear:animated];
|
|
|
- [self endTimer];
|
|
|
-// NSLog(@"viewWillDisappear-----");
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -1343,130 +1340,10 @@ static const CGFloat kQuoteViewHeight = 46.0f;
|
|
|
-(void)dismissBotton{
|
|
|
[self hidBottonView];
|
|
|
}
|
|
|
-#pragma mark 定时服务
|
|
|
--(void)startTimer{
|
|
|
- if(self.timer==nil){
|
|
|
- self.timer = [NSTimer scheduledTimerWithTimeInterval:10.1 target:self selector:@selector(TimerAction) userInfo:nil repeats:YES];
|
|
|
- [self.timer setFireDate:[NSDate distantPast]];
|
|
|
- [[NSRunLoop currentRunLoop] addTimer:_timer forMode:NSRunLoopCommonModes];
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
--(void)endTimer{
|
|
|
- [self.timer invalidate];
|
|
|
- self.timer = nil;
|
|
|
-}
|
|
|
-
|
|
|
--(void)TimerAction{
|
|
|
- //处理重发事件
|
|
|
-// NSLog(@"self.msgList:%@",self.msgList);
|
|
|
- for(NSDictionary *dis in self.msgList){
|
|
|
- NSString *mine = dis[@"mine"];
|
|
|
- if(mine.boolValue){
|
|
|
- if([dis[@"id"] isEqualToString:dis[@"localtime"]]){
|
|
|
- [self resendMsg:dis.copy];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
--(BOOL)canResend:(NSDictionary *)msg{
|
|
|
- NSLog(@"canResend:%@",msg);
|
|
|
- NSString *localtime = msg[@"localtime"];
|
|
|
- NSString *messageType = msg[@"messageType"];
|
|
|
- if([messageType isEqualToString:MessageType_text]){
|
|
|
- for (NSDictionary *item in self.msgList) {
|
|
|
- NSString *itlocaltime =item[@"localtime"];
|
|
|
- if([localtime isEqualToString:itlocaltime]){
|
|
|
- NSLog(@"canResend2:%@",item);
|
|
|
- if(![item[@"id"] isEqualToString:item[@"localtime"]]){
|
|
|
- return false;
|
|
|
- }
|
|
|
- NSDate *now = [NSDate date];
|
|
|
- NSTimeInterval trt = [now timeIntervalSince1970];
|
|
|
- NSNumber *tt =msg[@"localtime"];
|
|
|
- if((trt-tt.integerValue/1000)>40){
|
|
|
- //发送失败
|
|
|
- NSLog(@"发送失败-------");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- [self fileUploadState:msg];
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- return YES;
|
|
|
-}
|
|
|
-
|
|
|
--(void)fileUploadState:(NSDictionary *)msg{
|
|
|
- NSString *localtime = msg[@"localtime"];
|
|
|
- NSString *messageType = msg[@"messageType"];
|
|
|
- if([messageType isEqualToString:MessageType_file]||[messageType isEqualToString:MessageType_image]||[messageType isEqualToString:MessageType_video]) {
|
|
|
- if([OSSManager.sharedManager isuploadTanck:localtime]){
|
|
|
- return;
|
|
|
- }
|
|
|
- for (NSDictionary *item in self.msgList) {
|
|
|
-
|
|
|
- NSString *itlocaltime =item[@"localtime"];
|
|
|
- if([localtime isEqualToString:itlocaltime]){
|
|
|
- NSLog(@"canResend2:%@",item);
|
|
|
- if(![item[@"id"] isEqualToString:item[@"localtime"]]){
|
|
|
- return;
|
|
|
- }
|
|
|
- NSDictionary *extend =item[@"extend"];
|
|
|
- NSString *url =extend[@"url"];
|
|
|
- if([url isEqualToString:@""]){
|
|
|
- NSString *savedPath =extend[@"localurl"];
|
|
|
- NSURL * fileUrl = [NSURL fileURLWithPath:savedPath];
|
|
|
- ChatFileModel * model = [[ChatFileModel alloc] initWithURL:fileUrl];
|
|
|
- model.fileURL = fileUrl;
|
|
|
- model.filePath = savedPath;
|
|
|
- [self OSSuploadFile:model thrid:localtime];
|
|
|
- NSLog(@"重发文件");
|
|
|
- [self FileReUpload:localtime];
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
--(void)FileReUpload:(NSString *)localtime{
|
|
|
- [GDBManager.shareInstance selectLocalmsgWithLocaltime:localtime succ:^(NSArray * _Nullable array) {
|
|
|
- NSLog(@"selectLocalmsgWithLocaltime:%@",array);
|
|
|
-
|
|
|
- if(array){
|
|
|
- if(array.count>0){
|
|
|
- NSDictionary *msg =array[0];
|
|
|
- NSString *msgtype = msg[@"messageType"];
|
|
|
-
|
|
|
- if (([msgtype isEqualToString:MessageType_Del]||[msgtype isEqualToString:MessageType_CallBack2])) {
|
|
|
- return;
|
|
|
- }
|
|
|
- NSDictionary *extend=msg[@"extend"];
|
|
|
- NSMutableDictionary *mextend = [extend mutableCopy];
|
|
|
- [mextend setObject:[NSNumber numberWithInt:0] forKey:@"fileError"];
|
|
|
- NSMutableDictionary *mmsg = [msg mutableCopy];
|
|
|
- [mmsg setObject:mextend forKey:@"extend"];
|
|
|
- [ChatsStore.shareInstance reciveMsg:mmsg];
|
|
|
- }
|
|
|
- }
|
|
|
- } fail:^(NSString * _Nullable error) {
|
|
|
- ;
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
//重发消息
|
|
|
-(void)resendMsg:(NSDictionary *)msg{
|
|
|
- if(![self canResend:msg]){
|
|
|
- return;
|
|
|
- }
|
|
|
+
|
|
|
NSMutableDictionary *dic = [msg mutableCopy];
|
|
|
NSString *resend =dic[@"reSend"];
|
|
|
NSLog(@"resend:%@",[resend class]);
|