Merge pull request #401 from monich/authorizationState

Don't show Active Sessions button when not authenticated
This commit is contained in:
Sebastian Wolf 2021-02-25 21:25:35 +01:00 committed by GitHub
commit 8fabca8a0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 27 deletions

View file

@ -18,6 +18,7 @@
*/
import QtQuick 2.6
import Sailfish.Silica 1.0
import WerkWolf.Fernschreiber 1.0
import "../components"
import "../js/twemoji.js" as Emoji
@ -25,8 +26,7 @@ Page {
id: aboutPage
allowedOrientations: Orientation.All
property bool isLoggedIn : false
property var userInformation : tdLibWrapper.getUserInformation();
readonly property var userInformation : tdLibWrapper.userInformation
SilicaFlickable {
id: aboutContainer
@ -158,7 +158,7 @@ Page {
Loader {
id: userInformationLoader
active: isLoggedIn
active: tdLibWrapper.authorizationState === TelegramAPI.AuthorizationReady
width: parent.width
sourceComponent: Component {
Column {
@ -227,18 +227,18 @@ Page {
}
}
}
}
}
}
Button {
id: activeSessionsButton
text: qsTr("Active Sessions")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
pageStack.push(Qt.resolvedUrl("ActiveSessionsPage.qml"));
Button {
id: activeSessionsButton
text: qsTr("Active Sessions")
anchors {
horizontalCenter: parent.horizontalCenter
}
onClicked: {
pageStack.push(Qt.resolvedUrl("ActiveSessionsPage.qml"));
}
}
}
}
}

View file

@ -28,7 +28,7 @@ CoverBackground {
property int unreadMessages: 0
property int unreadChats: 0
property bool authenticated: false
readonly property bool authenticated: tdLibWrapper.authorizationState === TelegramAPI.AuthorizationReady
property int connectionState: TelegramAPI.WaitingForNetwork
function setUnreadInfoText() {
@ -56,7 +56,6 @@ CoverBackground {
}
Component.onCompleted: {
coverPage.authenticated = (tdLibWrapper.getAuthorizationState() === TelegramAPI.AuthorizationReady);
coverPage.connectionState = tdLibWrapper.getConnectionState();
coverPage.unreadMessages = tdLibWrapper.getUnreadMessageInformation().unread_count || 0;
coverPage.unreadChats = tdLibWrapper.getUnreadChatInformation().unread_count || 0;
@ -74,7 +73,6 @@ CoverBackground {
setUnreadInfoText();
}
onAuthorizationStateChanged: {
coverPage.authenticated = (authorizationState === TelegramAPI.AuthorizationReady);
setUnreadInfoText();
}
onConnectionStateChanged: {

View file

@ -26,15 +26,13 @@ Page {
backNavigation: false
property bool loading: true
property int authorizationState: TelegramAPI.Closed
property var authorizationStateData: null
Component.onCompleted: {
initializationPage.authorizationState = tdLibWrapper.getAuthorizationState();
initializationPage.authorizationStateData = tdLibWrapper.getAuthorizationStateData();
initializationPage.loading = false;
switch (authorizationState) {
switch (tdLibWrapper.authorizationState) {
case TelegramAPI.WaitCode:
initializationPage.loading = false;
welcomeColumn.visible = false;
@ -66,7 +64,7 @@ Page {
Connections {
target: tdLibWrapper
onAuthorizationStateChanged: {
switch (authorizationState) {
switch (tdLibWrapper.authorizationState) {
case TelegramAPI.WaitCode:
initializationPage.loading = false;
enterPinColumn.visible = true;

View file

@ -32,7 +32,6 @@ Page {
property bool initializationCompleted: false;
property bool loading: true;
property bool logoutLoading: false;
property int authorizationState: TelegramAPI.Closed
property int connectionState: TelegramAPI.WaitingForNetwork
property int ownUserId;
property bool chatListCreated: false;
@ -146,14 +145,13 @@ Page {
}
function initializePage() {
overviewPage.authorizationState = tdLibWrapper.getAuthorizationState();
overviewPage.handleAuthorizationState(true);
overviewPage.connectionState = tdLibWrapper.getConnectionState();
overviewPage.setPageStatus();
}
function handleAuthorizationState(isOnInitialization) {
switch (overviewPage.authorizationState) {
switch (tdLibWrapper.authorizationState) {
case TelegramAPI.WaitPhoneNumber:
case TelegramAPI.WaitCode:
case TelegramAPI.WaitPassword:
@ -204,8 +202,7 @@ Page {
Connections {
target: tdLibWrapper
onAuthorizationStateChanged: {
overviewPage.authorizationState = authorizationState;
handleAuthorizationState();
handleAuthorizationState(false);
}
onConnectionStateChanged: {
overviewPage.connectionState = connectionState;
@ -278,7 +275,7 @@ Page {
}
MenuItem {
text: qsTr("About Fernschreiber")
onClicked: pageStack.push(Qt.resolvedUrl("../pages/AboutPage.qml"), {isLoggedIn : (overviewPage.authorizationState == TelegramAPI.AuthorizationReady)})
onClicked: pageStack.push(Qt.resolvedUrl("../pages/AboutPage.qml"))
}
MenuItem {
text: qsTr("Settings")

View file

@ -31,6 +31,9 @@
class TDLibWrapper : public QObject
{
Q_OBJECT
Q_PROPERTY(AuthorizationState authorizationState READ getAuthorizationState NOTIFY authorizationStateChanged)
Q_PROPERTY(QVariantMap userInformation READ getUserInformation NOTIFY ownUserUpdated)
public:
explicit TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface, QObject *parent = nullptr);
~TDLibWrapper();