Skip to content

Commit

Permalink
Merge pull request #1757 from nextcloud/fix-negative-call-time
Browse files Browse the repository at this point in the history
Make sure callDuration is not negative
  • Loading branch information
SystemKeeper authored Aug 21, 2024
2 parents 1173e11 + 401a71b commit 82753e6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions NextcloudTalk/CallViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1264,13 +1264,17 @@ - (void)localVideoDragged:(UIPanGestureRecognizer *)gesture

- (void)callDurationTimerUpdate
{
NSTimeInterval currentTimestamp = [[NSDate date] timeIntervalSince1970];

// In case we are the ones who start the call, we don't have the server-side callStartTime, so we set it locally
if (self.room.callStartTime == 0) {
self.room.callStartTime = [[NSDate date] timeIntervalSince1970];
self.room.callStartTime = currentTimestamp;
}

NSTimeInterval currentTimestamp = [[NSDate date] timeIntervalSince1970];
long callDuration = currentTimestamp - self.room.callStartTime;
// Make sure that the remote callStartTime is not in the future
NSInteger callStartTime = MIN(self.room.callStartTime, currentTimestamp);

long callDuration = currentTimestamp - callStartTime;
long oneHourInSeconds = 60 * 60;

long hours = callDuration / 3600;
Expand Down

0 comments on commit 82753e6

Please sign in to comment.