Skip to content
Snippets Groups Projects
Commit a8b0adbe authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Andreas Traczyk
Browse files

mainview: code optimization for page on stack view checking

Change-Id: I8ff7122a430b73f1c5626ae931f13f5a4ffe242a
parent 9a20e2da
No related branches found
No related tags found
No related merge requests found
...@@ -70,13 +70,22 @@ Window { ...@@ -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() { function showWelcomeView() {
mainViewWindowSidePanel.deselectConversationSmartList() mainViewWindowSidePanel.deselectConversationSmartList()
if (communicationPageMessageWebView.visible || callStackView.visible) { if (isPageInStack("callStackViewObject", sidePanelViewStack) ||
isPageInStack("communicationPageMessageWebView", sidePanelViewStack) ||
isPageInStack("communicationPageMessageWebView", mainViewStack) ||
isPageInStack("callStackViewObject", mainViewStack)) {
sidePanelViewStack.pop(StackView.Immediate) sidePanelViewStack.pop(StackView.Immediate)
if (!sidePanelOnly) { mainViewStack.pop(welcomePage, StackView.Immediate)
mainViewStack.pop(welcomePage, StackView.Immediate)
}
} }
recordBox.visible = false recordBox.visible = false
} }
...@@ -112,7 +121,6 @@ Window { ...@@ -112,7 +121,6 @@ Window {
callStackView.updateCorrespondingUI() callStackView.updateCorrespondingUI()
} }
function pushCallStackView() { function pushCallStackView() {
if (sidePanelOnly) { if (sidePanelOnly) {
sidePanelViewStack.push(callStackView, StackView.Immediate) sidePanelViewStack.push(callStackView, StackView.Immediate)
...@@ -153,7 +161,6 @@ Window { ...@@ -153,7 +161,6 @@ Window {
} }
function toggleSettingsView() { function toggleSettingsView() {
inSettingsView = !inSettingsView inSettingsView = !inSettingsView
if (inSettingsView) { if (inSettingsView) {
...@@ -210,11 +217,8 @@ Window { ...@@ -210,11 +217,8 @@ Window {
// Check if call stack view is on any of the stackview. // Check if call stack view is on any of the stackview.
if (callStackView.responsibleAccountId === accountId if (callStackView.responsibleAccountId === accountId
&& callStackView.responsibleConvUid === convUid) { && callStackView.responsibleConvUid === convUid) {
if (mainViewStack.find(function (item, index) { if (isPageInStack("callStackViewObject", sidePanelViewStack) ||
return item.objectName === "callStackViewObject" isPageInStack("callStackViewObject", mainViewStack)) {
}) || sidePanelViewStack.find(function (item, index) {
return item.objectName === "callStackViewObject"
})) {
if (!inSettingsView) { if (!inSettingsView) {
callStackView.needToCloseInCallConversationAndPotentialWindow() callStackView.needToCloseInCallConversationAndPotentialWindow()
pushCommunicationMessageWebView() pushCommunicationMessageWebView()
...@@ -224,7 +228,6 @@ Window { ...@@ -224,7 +228,6 @@ Window {
} }
function onIncomingCallNeedToSetupMainView(accountId, convUid, fromNotification) { function onIncomingCallNeedToSetupMainView(accountId, convUid, fromNotification) {
// Set up the call stack view that is needed by call overlay. // Set up the call stack view that is needed by call overlay.
if (!inSettingsView) { if (!inSettingsView) {
mainViewStack.pop(welcomePage, StackView.Immediate) mainViewStack.pop(welcomePage, StackView.Immediate)
...@@ -478,15 +481,10 @@ Window { ...@@ -478,15 +481,10 @@ Window {
MessagesAdapter.setupChatView(currentUID) MessagesAdapter.setupChatView(currentUID)
callStackView.setLinkedWebview(communicationPageMessageWebView) callStackView.setLinkedWebview(communicationPageMessageWebView)
if (mainViewStack.find(function (item, index) { if (isPageInStack("communicationPageMessageWebView", sidePanelViewStack) ||
return item.objectName === "communicationPageMessageWebView" isPageInStack("communicationPageMessageWebView", mainViewStack)) {
}) || sidePanelViewStack.find(function (item, index) { if (!callStackViewShouldShow)
return item.objectName === "communicationPageMessageWebView"
})) {
if (!callStackViewShouldShow) {
communicationPageMessageWebView.focusMessageWebView()
return return
}
} }
// Push messageWebView or callStackView onto the correct stackview // Push messageWebView or callStackView onto the correct stackview
...@@ -541,7 +539,6 @@ Window { ...@@ -541,7 +539,6 @@ Window {
WelcomePage { WelcomePage {
id: welcomePage id: welcomePage
visible: false visible: false
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment