From 48be585561cc17aea314f90cbd1339e10e3f346b Mon Sep 17 00:00:00 2001 From: "Sebastian J. Wolf" Date: Tue, 18 Aug 2020 11:11:03 +0200 Subject: [PATCH] Finally the onboarding process seems to work properly --- qml/pages/InitializationPage.qml | 1 + qml/pages/OverviewPage.qml | 52 ++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/qml/pages/InitializationPage.qml b/qml/pages/InitializationPage.qml index 45ec32f..8e9b5aa 100644 --- a/qml/pages/InitializationPage.qml +++ b/qml/pages/InitializationPage.qml @@ -52,6 +52,7 @@ Page { break; case TelegramAPI.AuthorizationReady: initializationPage.loading = false; + pageStack.completeAnimation(); pageStack.pop(); break; default: diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml index cbcaa0a..912048e 100644 --- a/qml/pages/OverviewPage.qml +++ b/qml/pages/OverviewPage.qml @@ -28,10 +28,18 @@ Page { id: overviewPage allowedOrientations: Orientation.All + property bool initializationCompleted: false; property bool loading: true; property int authorizationState: TelegramAPI.Closed property int connectionState: TelegramAPI.WaitingForNetwork + onStatusChanged: { + console.log("[OverviewPage] Status changed: " + status + ", initialization completed: " + initializationCompleted); + if (status === PageStatus.Active && initializationCompleted) { + updateContent(); + } + } + BusyLabel { text: qsTr("Loading...") running: overviewPage.loading @@ -64,45 +72,45 @@ Page { function updateContent() { tdLibWrapper.getChats(); - } function initializePage() { overviewPage.authorizationState = tdLibWrapper.getAuthorizationState(); - if (overviewPage.authorizationState === TelegramAPI.AuthorizationReady) { - overviewPage.loading = false; - overviewPage.updateContent(); - } + overviewPage.handleAuthorizationState(); overviewPage.connectionState = tdLibWrapper.getConnectionState(); overviewPage.setPageStatus(); } + function handleAuthorizationState() { + switch (overviewPage.authorizationState) { + case TelegramAPI.WaitPhoneNumber: + overviewPage.loading = false; + pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml")); + break; + case TelegramAPI.WaitCode: + overviewPage.loading = false; + pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml")); + break; + case TelegramAPI.AuthorizationReady: + overviewPage.loading = false; + overviewPage.initializationCompleted = true; + overviewPage.updateContent(); + break; + default: + // Nothing ;) + } + } + Connections { target: tdLibWrapper onAuthorizationStateChanged: { - switch (authorizationState) { - case TelegramAPI.WaitPhoneNumber: - overviewPage.loading = false; - pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml")); - break; - case TelegramAPI.WaitCode: - overviewPage.loading = false; - pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml")); - break; - case TelegramAPI.AuthorizationReady: - overviewPage.loading = false; - overviewPage.updateContent(); - break; - default: - // Nothing ;) - } overviewPage.authorizationState = authorizationState; + handleAuthorizationState(); } onConnectionStateChanged: { overviewPage.connectionState = connectionState; setPageStatus(); } - } Component.onCompleted: {