Finally the onboarding process seems to work properly

This commit is contained in:
Sebastian J. Wolf 2020-08-18 11:11:03 +02:00
parent d55aa19a72
commit 48be585561
2 changed files with 31 additions and 22 deletions

View file

@ -52,6 +52,7 @@ Page {
break; break;
case TelegramAPI.AuthorizationReady: case TelegramAPI.AuthorizationReady:
initializationPage.loading = false; initializationPage.loading = false;
pageStack.completeAnimation();
pageStack.pop(); pageStack.pop();
break; break;
default: default:

View file

@ -28,10 +28,18 @@ Page {
id: overviewPage id: overviewPage
allowedOrientations: Orientation.All allowedOrientations: Orientation.All
property bool initializationCompleted: false;
property bool loading: true; property bool loading: true;
property int authorizationState: TelegramAPI.Closed property int authorizationState: TelegramAPI.Closed
property int connectionState: TelegramAPI.WaitingForNetwork property int connectionState: TelegramAPI.WaitingForNetwork
onStatusChanged: {
console.log("[OverviewPage] Status changed: " + status + ", initialization completed: " + initializationCompleted);
if (status === PageStatus.Active && initializationCompleted) {
updateContent();
}
}
BusyLabel { BusyLabel {
text: qsTr("Loading...") text: qsTr("Loading...")
running: overviewPage.loading running: overviewPage.loading
@ -64,45 +72,45 @@ Page {
function updateContent() { function updateContent() {
tdLibWrapper.getChats(); tdLibWrapper.getChats();
} }
function initializePage() { function initializePage() {
overviewPage.authorizationState = tdLibWrapper.getAuthorizationState(); overviewPage.authorizationState = tdLibWrapper.getAuthorizationState();
if (overviewPage.authorizationState === TelegramAPI.AuthorizationReady) { overviewPage.handleAuthorizationState();
overviewPage.loading = false;
overviewPage.updateContent();
}
overviewPage.connectionState = tdLibWrapper.getConnectionState(); overviewPage.connectionState = tdLibWrapper.getConnectionState();
overviewPage.setPageStatus(); 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 { Connections {
target: tdLibWrapper target: tdLibWrapper
onAuthorizationStateChanged: { 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; overviewPage.authorizationState = authorizationState;
handleAuthorizationState();
} }
onConnectionStateChanged: { onConnectionStateChanged: {
overviewPage.connectionState = connectionState; overviewPage.connectionState = connectionState;
setPageStatus(); setPageStatus();
} }
} }
Component.onCompleted: { Component.onCompleted: {