diff --git a/src/gui/MainPane/AccountContextMenu.qml b/src/gui/MainPane/AccountContextMenu.qml index f910fdbb..f7a54a17 100644 --- a/src/gui/MainPane/AccountContextMenu.qml +++ b/src/gui/MainPane/AccountContextMenu.qml @@ -111,7 +111,8 @@ HMenu { text: qsTr("Account settings") onTriggered: { pageLoader.showPage( - "AccountSettings/AccountSettings", { "userId": userId }, + "Pages/AccountSettings/AccountSettings.qml", + { "userId": userId }, ) wentToAccountPage() } @@ -121,7 +122,7 @@ HMenu { icon.name: "menu-add-chat" text: qsTr("Add new chat") onTriggered: { - pageLoader.showPage("AddChat/AddChat", {userId: userId}) + pageLoader.showPage("Pages/AddChat/AddChat.qml", {userId: userId}) wentToAccountPage() } } diff --git a/src/gui/MainPane/AccountDelegate.qml b/src/gui/MainPane/AccountDelegate.qml index 18e4b818..5a7e892e 100644 --- a/src/gui/MainPane/AccountDelegate.qml +++ b/src/gui/MainPane/AccountDelegate.qml @@ -146,7 +146,9 @@ HTile { backgroundColor: "transparent" toolTip.text: qsTr("Add new chat") onClicked: { - pageLoader.showPage("AddChat/AddChat", {userId: model.id}) + pageLoader.showPage( + "Pages/AddChat/AddChat.qml", {userId: model.id}, + ) account.wentToAccountPage() } diff --git a/src/gui/MainPane/BottomBar.qml b/src/gui/MainPane/BottomBar.qml index d14f7ab7..deda1097 100644 --- a/src/gui/MainPane/BottomBar.qml +++ b/src/gui/MainPane/BottomBar.qml @@ -24,7 +24,7 @@ Rectangle { toolTip.text: qsTr("Add another account") backgroundColor: theme.mainPane.bottomBar.settingsButtonBackground onClicked: { - pageLoader.showPage("AddAccount/AddAccount") + pageLoader.showPage("Pages/AddAccount/AddAccount.qml") roomList.startCorrectItemSearch() } diff --git a/src/gui/MainPane/RoomList.qml b/src/gui/MainPane/RoomList.qml index 5468c0e0..f12ab968 100644 --- a/src/gui/MainPane/RoomList.qml +++ b/src/gui/MainPane/RoomList.qml @@ -62,7 +62,7 @@ HListView { item.type === "Account" ? pageLoader.showPage( - "AccountSettings/AccountSettings", { "userId": item.id } + "Pages/AccountSettings/AccountSettings.qml", { "userId": item.id }, ) : pageLoader.showRoom(item.for_account, item.id) diff --git a/src/gui/PageLoader.qml b/src/gui/PageLoader.qml index 8802e7bf..ec346b45 100644 --- a/src/gui/PageLoader.qml +++ b/src/gui/PageLoader.qml @@ -21,35 +21,29 @@ HLoader { signal previousShown(string componentUrl, var properties) - function _show(componentUrl, properties={}) { + function showPage(componentUrl, properties={}) { history.unshift([componentUrl, properties]) if (history.length > historyLength) history.pop() - pageLoader.setSource(componentUrl, properties) - } + const recycle = + window.uiState.page === componentUrl && + componentUrl === "Pages/Chat/Chat.qml" && + item - function showPage(name, properties={}) { - const path = `Pages/${name}.qml` - _show(path, properties) + if (recycle) { + for (const [prop, value] of Object.entries(properties)) + item[prop] = value + } else { + pageLoader.setSource(componentUrl, properties) + window.uiState.page = componentUrl + } - window.uiState.page = path window.uiState.pageProperties = properties window.uiStateChanged() } function showRoom(userId, roomId) { - if (window.uiState.page === "Pages/Chat/Chat.qml" && item) { - // XXX: showPrevious - item.userId = userId - item.roomId = roomId - return - } - - _show("Pages/Chat/Chat.qml", {userId, roomId}) - - window.uiState.page = "Pages/Chat/Chat.qml" - window.uiState.pageProperties = {userId, roomId} - window.uiStateChanged() + showPage("Pages/Chat/Chat.qml", {userId, roomId}) } function showPrevious(timesBack=1) { @@ -57,12 +51,7 @@ HLoader { if (timesBack < 1) return false const [componentUrl, properties] = history[timesBack] - - _show(componentUrl, properties) - - window.uiState.page = componentUrl - window.uiState.pageProperties = properties - window.uiStateChanged() + showPage(componentUrl, properties) previousShown(componentUrl, properties) return true } diff --git a/src/gui/Pages/AddAccount/SignInBase.qml b/src/gui/Pages/AddAccount/SignInBase.qml index df01b72e..dc5ad5b2 100644 --- a/src/gui/Pages/AddAccount/SignInBase.qml +++ b/src/gui/Pages/AddAccount/SignInBase.qml @@ -46,7 +46,8 @@ HFlickableColumnPage { ) pageLoader.showPage( - "AccountSettings/AccountSettings", {userId: receivedUserId} + "Pages/AccountSettings/AccountSettings.qml", + {userId: receivedUserId}, ) } diff --git a/src/gui/Popups/ForgetRoomPopup.qml b/src/gui/Popups/ForgetRoomPopup.qml index a6656308..edc8d58a 100644 --- a/src/gui/Popups/ForgetRoomPopup.qml +++ b/src/gui/Popups/ForgetRoomPopup.qml @@ -20,7 +20,7 @@ HFlickableColumnPopup { window.uiState.pageProperties.roomId === roomId) { window.mainUI.pageLoader.showPrevious() || - window.mainUI.pageLoader.showPage("Default") + window.mainUI.pageLoader.showPage("Pages/Default.qml") Qt.callLater(popup.destroy) } diff --git a/src/gui/Popups/SignOutPopup.qml b/src/gui/Popups/SignOutPopup.qml index 0f31faab..57303646 100644 --- a/src/gui/Popups/SignOutPopup.qml +++ b/src/gui/Popups/SignOutPopup.qml @@ -38,7 +38,8 @@ HFlickableColumnPopup { if (ModelStore.get("accounts").count < 2 || window.uiState.pageProperties.userId === userId) { - window.mainUI.pageLoader.showPage("AddAccount/AddAccount") + const page = "Pages/AddAccount/AddAccount.qml" + window.mainUI.pageLoader.showPage(page) } py.callCoro("logout_client", [userId])