Merge pull request #204 from jgibbon/bugfix/auth-handling
Fix initial auth handling
This commit is contained in:
commit
fff8fc903a
2 changed files with 16 additions and 3 deletions
|
@ -68,6 +68,14 @@ Page {
|
|||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: openInitializationPageTimer
|
||||
interval: 0
|
||||
onTriggered: {
|
||||
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
|
||||
}
|
||||
}
|
||||
|
||||
function setPageStatus() {
|
||||
switch (overviewPage.connectionState) {
|
||||
case TelegramAPI.WaitingForNetwork:
|
||||
|
@ -101,19 +109,23 @@ Page {
|
|||
|
||||
function initializePage() {
|
||||
overviewPage.authorizationState = tdLibWrapper.getAuthorizationState();
|
||||
overviewPage.handleAuthorizationState();
|
||||
overviewPage.handleAuthorizationState(true);
|
||||
overviewPage.connectionState = tdLibWrapper.getConnectionState();
|
||||
overviewPage.setPageStatus();
|
||||
}
|
||||
|
||||
function handleAuthorizationState() {
|
||||
function handleAuthorizationState(isOnInitialization) {
|
||||
switch (overviewPage.authorizationState) {
|
||||
case TelegramAPI.WaitPhoneNumber:
|
||||
case TelegramAPI.WaitCode:
|
||||
case TelegramAPI.WaitPassword:
|
||||
case TelegramAPI.WaitRegistration:
|
||||
overviewPage.loading = false;
|
||||
if(isOnInitialization) { // pageStack isn't ready on Component.onCompleted
|
||||
openInitializationPageTimer.start()
|
||||
} else {
|
||||
pageStack.push(Qt.resolvedUrl("../pages/InitializationPage.qml"));
|
||||
}
|
||||
break;
|
||||
case TelegramAPI.AuthorizationReady:
|
||||
overviewPage.loading = false;
|
||||
|
|
|
@ -49,6 +49,7 @@ TDLibWrapper::TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface,
|
|||
this->appSettings = appSettings;
|
||||
this->mceInterface = mceInterface;
|
||||
this->tdLibClient = td_json_client_create();
|
||||
this->authorizationState = AuthorizationState::Closed;
|
||||
this->tdLibReceiver = new TDLibReceiver(this->tdLibClient, this);
|
||||
|
||||
QString tdLibDatabaseDirectoryPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/tdlib";
|
||||
|
|
Loading…
Reference in a new issue