Advertisement
Guest User

Untitled

a guest
Nov 12th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (NSNumber *)maxServerResultCount {
  2.     return @(200);
  3. }
  4.  
  5. - (void)updateCallRecordsInternal
  6. {
  7.     LogMethodName();
  8.     self.regetHistoryRequired = NO;
  9.     self.updatingHistoryNow = YES;
  10.    
  11.     [self fireWsMethodRequested];
  12.    
  13.     NSNumber *minMasterId = self.maxMasterId;
  14.     [self.webService fetchRecentActivityWithTypes:@"VOICE"
  15.                                       minMasterID:minMasterId
  16.                                          quantity:self.maxServerResultCount
  17.                        compressRecentActivityList:YES
  18.                                        completion:^(WSMethodCompletionStatus completionStatus, id result)
  19.      {
  20.          @synchronized (self) {
  21.              self.updatingHistoryNow = NO;
  22.          }
  23.          
  24.          if (completionStatus == WSMethodCompletionStatusOk) {
  25.              
  26.              WSFetchRecentActivityResult *recentActivityResult = result;
  27.              
  28.              NSLog(@"---> Server Records count: %d", recentActivityResult.recentActivity.count);
  29.              NSLog(@"-->Last record:\n -->%@", recentActivityResult.recentActivity.lastObject);
  30.              
  31.              [self addAllRecentActivityRecords:recentActivityResult.recentActivity];
  32.              
  33.              //Continue to loading records until count of received records
  34.              //lower than max server records count per one request
  35.              WSServerRecentActivityRecord *lastRecord = recentActivityResult.recentActivity.lastObject;
  36.              
  37.              if (recentActivityResult.recentActivity.count == self.maxServerResultCount.unsignedLongLongValue && lastRecord) {
  38.                  self.prevMinMasterId = lastRecord.masterId;
  39.                  [self updateCallRecordsInternal];
  40.              } else {
  41.                  [self fireWsMethodReceived];
  42.              }
  43.  
  44. //             if (recentActivityResult.recentActivity.count > 0) {
  45. //                 NSNumber *maxMasterId = self.maxMasterId;
  46. //                 if (![maxMasterId isEqualToNumber:@(0)]) {
  47. //                     self.prevMinMasterId = self.maxMasterId;
  48. //                 }
  49. //             }
  50.          }
  51.          else if (completionStatus == WSMethodCompletionStatusCanceled) {
  52.              NSAssert(NO, @"WSMethodCompletionStatusCanceled");
  53.              // do nothing
  54.          }
  55.          else {
  56.              NSAssert(NO, @"couldn't retrieve recent activity records");
  57.  
  58.              LogError(@"couldn't retrieve recent activity records: '%@'", ((NSException *)result).reason);
  59.          }
  60.          
  61.      }];
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement