Commit 66a050cc authored by Anthony Léonard's avatar Anthony Léonard Committed by Kateryna Kostiuk

implement call duration display with NewCallModel

This NSTextField was hidden as it wasn't reimplemented during the
NewCallModel refactoring in CurrentCallVC. It is now working as
expected by asking the model once per second for the new duration
value.

Change-Id: I27bd8f578ce5010e9311938f71ca610197f7357b
Reviewed-by: Kateryna Kostiuk's avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent 8585cc01
......@@ -62,6 +62,7 @@
std::string convUid_;
std::string callUid_;
const lrc::api::account::Info *accountInfo_;
NSTimer* refreshDurationTimer;
}
// Main container
......@@ -177,6 +178,28 @@
[self.videoView setCallDelegate:self];
}
-(void) updateDurationLabel
{
if (accountInfo_ != nil) {
auto* callModel = accountInfo_->callModel.get();
if (callModel->hasCall(callUid_)) {
auto& callStatus = callModel->getCall(callUid_).status;
if (callStatus != lrc::api::call::Status::ENDED &&
callStatus != lrc::api::call::Status::TERMINATING &&
callStatus != lrc::api::call::Status::INVALID) {
[timeSpentLabel setStringValue:@(callModel->getFormattedCallDuration(callUid_).c_str())];
return;
}
}
}
// If call is not running anymore or accountInfo_ is not set for any reason
// we stop the refresh loop
[refreshDurationTimer invalidate];
refreshDurationTimer = nil;
[timeSpentLabel setHidden:YES];
}
-(void) updateCall:(BOOL) firstRun
{
if (accountInfo_ == nil)
......@@ -190,7 +213,14 @@
auto currentCall = callModel->getCall(callUid_);
NSLog(@"\n status %@ \n",@(lrc::api::call::to_string(currentCall.status).c_str()));
[personLabel setStringValue:@(currentCall.peer.c_str())];
// [timeSpentLabel setStringValue:callIdx.data((int)Call::Role::Length).toString().toNSString()];
[timeSpentLabel setStringValue:@(callModel->getFormattedCallDuration(callUid_).c_str())];
[timeSpentLabel setHidden:NO];
if (refreshDurationTimer == nil)
refreshDurationTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(updateDurationLabel)
userInfo:nil
repeats:YES];
[stateLabel setStringValue:@(to_string(currentCall.status).c_str())];
if (firstRun) {
......
......@@ -56,7 +56,7 @@
<customView translatesAutoresizingMaskIntoConstraints="NO" id="d0X-cW-Xgz">
<rect key="frame" x="20" y="438" width="705" height="71"/>
<subviews>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cIU-M7-xpN">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cIU-M7-xpN">
<rect key="frame" x="583" y="23" width="104" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="9vz-kb-6L6"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment