1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-07-13 20:15:23 +02:00

mainview: code optimization for page on stack view checking

Change-Id: I8ff7122a430b73f1c5626ae931f13f5a4ffe242a
This commit is contained in:
Ming Rui Zhang 2020-09-24 16:33:26 -04:00 committed by Andreas Traczyk
parent 9a20e2da1a
commit a8b0adbef7

View file

@ -70,13 +70,22 @@ Window {
}
}
function isPageInStack(objectName, stackView) {
var foundItem = stackView.find(function (item, index) {
return item.objectName === objectName
})
return foundItem ? true : false
}
function showWelcomeView() {
mainViewWindowSidePanel.deselectConversationSmartList()
if (communicationPageMessageWebView.visible || callStackView.visible) {
if (isPageInStack("callStackViewObject", sidePanelViewStack) ||
isPageInStack("communicationPageMessageWebView", sidePanelViewStack) ||
isPageInStack("communicationPageMessageWebView", mainViewStack) ||
isPageInStack("callStackViewObject", mainViewStack)) {
sidePanelViewStack.pop(StackView.Immediate)
if (!sidePanelOnly) {
mainViewStack.pop(welcomePage, StackView.Immediate)
}
mainViewStack.pop(welcomePage, StackView.Immediate)
}
recordBox.visible = false
}
@ -112,7 +121,6 @@ Window {
callStackView.updateCorrespondingUI()
}
function pushCallStackView() {
if (sidePanelOnly) {
sidePanelViewStack.push(callStackView, StackView.Immediate)
@ -153,7 +161,6 @@ Window {
}
function toggleSettingsView() {
inSettingsView = !inSettingsView
if (inSettingsView) {
@ -210,11 +217,8 @@ Window {
// Check if call stack view is on any of the stackview.
if (callStackView.responsibleAccountId === accountId
&& callStackView.responsibleConvUid === convUid) {
if (mainViewStack.find(function (item, index) {
return item.objectName === "callStackViewObject"
}) || sidePanelViewStack.find(function (item, index) {
return item.objectName === "callStackViewObject"
})) {
if (isPageInStack("callStackViewObject", sidePanelViewStack) ||
isPageInStack("callStackViewObject", mainViewStack)) {
if (!inSettingsView) {
callStackView.needToCloseInCallConversationAndPotentialWindow()
pushCommunicationMessageWebView()
@ -224,7 +228,6 @@ Window {
}
function onIncomingCallNeedToSetupMainView(accountId, convUid, fromNotification) {
// Set up the call stack view that is needed by call overlay.
if (!inSettingsView) {
mainViewStack.pop(welcomePage, StackView.Immediate)
@ -478,15 +481,10 @@ Window {
MessagesAdapter.setupChatView(currentUID)
callStackView.setLinkedWebview(communicationPageMessageWebView)
if (mainViewStack.find(function (item, index) {
return item.objectName === "communicationPageMessageWebView"
}) || sidePanelViewStack.find(function (item, index) {
return item.objectName === "communicationPageMessageWebView"
})) {
if (!callStackViewShouldShow) {
communicationPageMessageWebView.focusMessageWebView()
if (isPageInStack("communicationPageMessageWebView", sidePanelViewStack) ||
isPageInStack("communicationPageMessageWebView", mainViewStack)) {
if (!callStackViewShouldShow)
return
}
}
// Push messageWebView or callStackView onto the correct stackview
@ -541,7 +539,6 @@ Window {
WelcomePage {
id: welcomePage
visible: false
}