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;
case TelegramAPI.AuthorizationReady:
initializationPage.loading = false;
pageStack.completeAnimation();
pageStack.pop();
break;
default:

View file

@ -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: {