From 87c9801472d4aa2752afb1b8931276998fd89c2c Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 7 Aug 2018 14:46:51 +0200 Subject: [PATCH] fix(Call): disable menu options if video is not supported or pause disabled --- ui/modules/Linphone/Calls/Calls.js | 53 ++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/ui/modules/Linphone/Calls/Calls.js b/ui/modules/Linphone/Calls/Calls.js index 4e5a0c78e..fa4b95be9 100644 --- a/ui/modules/Linphone/Calls/Calls.js +++ b/ui/modules/Linphone/Calls/Calls.js @@ -19,17 +19,22 @@ function getParams (call) { var status = call.status if (status === CallModel.CallStatusConnected) { - return { - actions: [{ + var optActions = [] + if (Linphone.SettingsModel.callPauseEnabled) { + optActions.push({ handler: (function () { call.pausedByUser = true }), name: qsTr('callPause') - }, { + }) + } + + return { + actions: optActions.concat([{ handler: call.askForTransfer, name: qsTr('transferCall') }, { handler: call.terminate, name: qsTr('terminateCall') - }], + }]), component: callActions, string: 'connected' } @@ -42,17 +47,22 @@ function getParams (call) { } if (status === CallModel.CallStatusIncoming) { + var optActions = [] + if (Linphone.SettingsModel.videoSupported) { + optActions.push({ + handler: call.acceptWithVideo, + name: qsTr('acceptVideoCall') + }) + } + return { actions: [{ - name: qsTr('acceptAudioCall'), - handler: (function () { call.accept() }) - }, { - name: qsTr('acceptVideoCall'), - handler: call.acceptWithVideo - }, { - name: qsTr('terminateCall'), - handler: call.terminate - }], + handler: (function () { call.accept() }), + name: qsTr('acceptAudioCall') + }].concat(optActions).concat([{ + handler: call.terminate, + name: qsTr('terminateCall') + }]), component: callActions, string: 'incoming' } @@ -68,20 +78,27 @@ function getParams (call) { } if (status === CallModel.CallStatusPaused) { - return { - actions: [(call.pausedByUser ? { + var optActions = [] + if (call.pausedByUser) { + optActions.push({ handler: (function () { call.pausedByUser = false }), name: qsTr('resumeCall') - } : { + }) + } else if (Linphone.SettingsModel.callPauseEnabled) { + optActions.push({ handler: (function () { call.pausedByUser = true }), name: qsTr('callPause') - }), { + }) + } + + return { + actions: optActions.concat([{ handler: call.askForTransfer, name: qsTr('transferCall') }, { handler: call.terminate, name: qsTr('terminateCall') - }], + }]), component: callActions, string: 'paused' }