From df920da2a6c6f7ca88125a6fdc5fce78bbcb4856 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 21 Jul 2019 08:54:32 -0400 Subject: [PATCH] Save & restore previous page when relaunching app --- src/qml/UI.qml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/qml/UI.qml b/src/qml/UI.qml index f4177599..1ae20113 100644 --- a/src/qml/UI.qml +++ b/src/qml/UI.qml @@ -15,7 +15,15 @@ Item { target: py onWillLoadAccounts: will => { if (! will) { pageStack.showPage("SignIn") } - pageStack.show(window.uiState.page) + + let page = window.uiState.page + let props = window.uiState.pageProperties + + if (page == "Chat/Chat.qml") { + pageStack.showRoom(props.userId, props.category, props.roomId) + } else { + pageStack.show(page, props) + } } } @@ -65,12 +73,21 @@ Item { } function showPage(name, properties={}) { - show("Pages/" + name + ".qml", properties) + let path = "Pages/" + name + ".qml" + show(path, properties) + + window.uiState.page = path + window.uiState.pageProperties = properties + window.uiStateChanged() } function showRoom(userId, category, roomId) { let roomInfo = rooms.find(userId, category, roomId) show("Chat/Chat.qml", {roomInfo}) + + window.uiState.page = "Chat/Chat.qml" + window.uiState.pageProperties = {userId, category, roomId} + window.uiStateChanged() } onCurrentItemChanged: if (currentItem) {