WFCUReceiptViewController.m 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // WFCUReceiptViewController.m
  3. // WFChatUIKit
  4. //
  5. // Created by heavyrain2012 on 2020/5/20.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUReceiptViewController.h"
  9. @interface WFCUReceiptViewController ()
  10. @property (nonatomic, strong)NSMutableDictionary<NSString *, NSNumber *> *deliveryDict;
  11. @property (nonatomic, strong)NSMutableDictionary<NSString *, NSNumber *> *readDict;
  12. @property (nonatomic, strong)NSMutableArray *deliveredUserIds;
  13. @property (nonatomic, strong)NSMutableArray *unDeliveredUserIds;
  14. @property (nonatomic, strong)NSMutableArray *readedUserIds;
  15. @property (nonatomic, strong)NSMutableArray *unReadedUserIds;
  16. @end
  17. @implementation WFCUReceiptViewController
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.view.backgroundColor = [UIColor whiteColor];
  21. if (self.message.conversation.type != Group_Type) {
  22. [self.navigationController popViewControllerAnimated:YES];
  23. return;
  24. }
  25. self.deliveryDict = [[WFCCIMService sharedWFCIMService] getMessageDelivery:self.message.conversation];
  26. self.readDict = [[WFCCIMService sharedWFCIMService] getConversationRead:self.message.conversation];
  27. self.deliveredUserIds = [[NSMutableArray alloc] init];
  28. self.readedUserIds = [[NSMutableArray alloc] init];
  29. int64_t sendTime = self.message.serverTime;
  30. [self.deliveryDict enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSNumber * _Nonnull obj, BOOL * _Nonnull stop) {
  31. if ([obj longLongValue] >= sendTime) {
  32. [self.deliveredUserIds addObject:key];
  33. }
  34. }];
  35. [self.readDict enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSNumber * _Nonnull obj, BOOL * _Nonnull stop) {
  36. if ([obj longLongValue] >= sendTime) {
  37. [self.readedUserIds addObject:key];
  38. }
  39. }];
  40. self.unDeliveredUserIds = [[NSMutableArray alloc] init];
  41. self.unReadedUserIds = [[NSMutableArray alloc] init];
  42. NSArray<WFCCGroupMember *> *members = [[WFCCIMService sharedWFCIMService] getGroupMembers:self.message.conversation.target forceUpdate:NO];
  43. for (WFCCGroupMember *member in members) {
  44. if (![self.deliveredUserIds containsObject:member.memberId]) {
  45. [self.unDeliveredUserIds addObject:member.memberId];
  46. }
  47. if (![self.readedUserIds containsObject:member.memberId]) {
  48. [self.unReadedUserIds addObject:member.memberId];
  49. }
  50. }
  51. [self.deliveredUserIds removeObject:self.message.fromUser];
  52. [self.unDeliveredUserIds removeObject:self.message.fromUser];
  53. [self.readedUserIds removeObject:self.message.fromUser];
  54. [self.unReadedUserIds removeObject:self.message.fromUser];
  55. UILabel *label = [[UILabel alloc] initWithFrame:self.view.bounds];
  56. label.numberOfLines = 0;
  57. label.text = [NSString stringWithFormat:@"%ld 成员已经收到消息, %ld 成员还未收到消息;%ld 成员已经阅读了消息,%ld 成员没有阅读消息", self.deliveredUserIds.count, self.unDeliveredUserIds.count, self.readedUserIds.count, self.unReadedUserIds.count];
  58. [self.view addSubview:label];
  59. }
  60. /*
  61. #pragma mark - Navigation
  62. // In a storyboard-based application, you will often want to do a little preparation before navigation
  63. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  64. // Get the new view controller using [segue destinationViewController].
  65. // Pass the selected object to the new view controller.
  66. }
  67. */
  68. @end