Merge pull request #401 from monich/authorizationState
Don't show Active Sessions button when not authenticated
This commit is contained in:
commit
8fabca8a0d
5 changed files with 23 additions and 27 deletions
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
import QtQuick 2.6
|
import QtQuick 2.6
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
|
import WerkWolf.Fernschreiber 1.0
|
||||||
import "../components"
|
import "../components"
|
||||||
import "../js/twemoji.js" as Emoji
|
import "../js/twemoji.js" as Emoji
|
||||||
|
|
||||||
|
@ -25,8 +26,7 @@ Page {
|
||||||
id: aboutPage
|
id: aboutPage
|
||||||
allowedOrientations: Orientation.All
|
allowedOrientations: Orientation.All
|
||||||
|
|
||||||
property bool isLoggedIn : false
|
readonly property var userInformation : tdLibWrapper.userInformation
|
||||||
property var userInformation : tdLibWrapper.getUserInformation();
|
|
||||||
|
|
||||||
SilicaFlickable {
|
SilicaFlickable {
|
||||||
id: aboutContainer
|
id: aboutContainer
|
||||||
|
@ -158,7 +158,7 @@ Page {
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: userInformationLoader
|
id: userInformationLoader
|
||||||
active: isLoggedIn
|
active: tdLibWrapper.authorizationState === TelegramAPI.AuthorizationReady
|
||||||
width: parent.width
|
width: parent.width
|
||||||
sourceComponent: Component {
|
sourceComponent: Component {
|
||||||
Column {
|
Column {
|
||||||
|
@ -227,9 +227,6 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
id: activeSessionsButton
|
id: activeSessionsButton
|
||||||
|
@ -241,6 +238,9 @@ Page {
|
||||||
pageStack.push(Qt.resolvedUrl("ActiveSessionsPage.qml"));
|
pageStack.push(Qt.resolvedUrl("ActiveSessionsPage.qml"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: qsTr("Terms of Service")
|
text: qsTr("Terms of Service")
|
||||||
|
|
|
@ -28,7 +28,7 @@ CoverBackground {
|
||||||
|
|
||||||
property int unreadMessages: 0
|
property int unreadMessages: 0
|
||||||
property int unreadChats: 0
|
property int unreadChats: 0
|
||||||
property bool authenticated: false
|
readonly property bool authenticated: tdLibWrapper.authorizationState === TelegramAPI.AuthorizationReady
|
||||||
property int connectionState: TelegramAPI.WaitingForNetwork
|
property int connectionState: TelegramAPI.WaitingForNetwork
|
||||||
|
|
||||||
function setUnreadInfoText() {
|
function setUnreadInfoText() {
|
||||||
|
@ -56,7 +56,6 @@ CoverBackground {
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
coverPage.authenticated = (tdLibWrapper.getAuthorizationState() === TelegramAPI.AuthorizationReady);
|
|
||||||
coverPage.connectionState = tdLibWrapper.getConnectionState();
|
coverPage.connectionState = tdLibWrapper.getConnectionState();
|
||||||
coverPage.unreadMessages = tdLibWrapper.getUnreadMessageInformation().unread_count || 0;
|
coverPage.unreadMessages = tdLibWrapper.getUnreadMessageInformation().unread_count || 0;
|
||||||
coverPage.unreadChats = tdLibWrapper.getUnreadChatInformation().unread_count || 0;
|
coverPage.unreadChats = tdLibWrapper.getUnreadChatInformation().unread_count || 0;
|
||||||
|
@ -74,7 +73,6 @@ CoverBackground {
|
||||||
setUnreadInfoText();
|
setUnreadInfoText();
|
||||||
}
|
}
|
||||||
onAuthorizationStateChanged: {
|
onAuthorizationStateChanged: {
|
||||||
coverPage.authenticated = (authorizationState === TelegramAPI.AuthorizationReady);
|
|
||||||
setUnreadInfoText();
|
setUnreadInfoText();
|
||||||
}
|
}
|
||||||
onConnectionStateChanged: {
|
onConnectionStateChanged: {
|
||||||
|
|
|
@ -26,15 +26,13 @@ Page {
|
||||||
backNavigation: false
|
backNavigation: false
|
||||||
|
|
||||||
property bool loading: true
|
property bool loading: true
|
||||||
property int authorizationState: TelegramAPI.Closed
|
|
||||||
property var authorizationStateData: null
|
property var authorizationStateData: null
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
initializationPage.authorizationState = tdLibWrapper.getAuthorizationState();
|
|
||||||
initializationPage.authorizationStateData = tdLibWrapper.getAuthorizationStateData();
|
initializationPage.authorizationStateData = tdLibWrapper.getAuthorizationStateData();
|
||||||
initializationPage.loading = false;
|
initializationPage.loading = false;
|
||||||
|
|
||||||
switch (authorizationState) {
|
switch (tdLibWrapper.authorizationState) {
|
||||||
case TelegramAPI.WaitCode:
|
case TelegramAPI.WaitCode:
|
||||||
initializationPage.loading = false;
|
initializationPage.loading = false;
|
||||||
welcomeColumn.visible = false;
|
welcomeColumn.visible = false;
|
||||||
|
@ -66,7 +64,7 @@ Page {
|
||||||
Connections {
|
Connections {
|
||||||
target: tdLibWrapper
|
target: tdLibWrapper
|
||||||
onAuthorizationStateChanged: {
|
onAuthorizationStateChanged: {
|
||||||
switch (authorizationState) {
|
switch (tdLibWrapper.authorizationState) {
|
||||||
case TelegramAPI.WaitCode:
|
case TelegramAPI.WaitCode:
|
||||||
initializationPage.loading = false;
|
initializationPage.loading = false;
|
||||||
enterPinColumn.visible = true;
|
enterPinColumn.visible = true;
|
||||||
|
|
|
@ -32,7 +32,6 @@ Page {
|
||||||
property bool initializationCompleted: false;
|
property bool initializationCompleted: false;
|
||||||
property bool loading: true;
|
property bool loading: true;
|
||||||
property bool logoutLoading: false;
|
property bool logoutLoading: false;
|
||||||
property int authorizationState: TelegramAPI.Closed
|
|
||||||
property int connectionState: TelegramAPI.WaitingForNetwork
|
property int connectionState: TelegramAPI.WaitingForNetwork
|
||||||
property int ownUserId;
|
property int ownUserId;
|
||||||
property bool chatListCreated: false;
|
property bool chatListCreated: false;
|
||||||
|
@ -146,14 +145,13 @@ Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializePage() {
|
function initializePage() {
|
||||||
overviewPage.authorizationState = tdLibWrapper.getAuthorizationState();
|
|
||||||
overviewPage.handleAuthorizationState(true);
|
overviewPage.handleAuthorizationState(true);
|
||||||
overviewPage.connectionState = tdLibWrapper.getConnectionState();
|
overviewPage.connectionState = tdLibWrapper.getConnectionState();
|
||||||
overviewPage.setPageStatus();
|
overviewPage.setPageStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAuthorizationState(isOnInitialization) {
|
function handleAuthorizationState(isOnInitialization) {
|
||||||
switch (overviewPage.authorizationState) {
|
switch (tdLibWrapper.authorizationState) {
|
||||||
case TelegramAPI.WaitPhoneNumber:
|
case TelegramAPI.WaitPhoneNumber:
|
||||||
case TelegramAPI.WaitCode:
|
case TelegramAPI.WaitCode:
|
||||||
case TelegramAPI.WaitPassword:
|
case TelegramAPI.WaitPassword:
|
||||||
|
@ -204,8 +202,7 @@ Page {
|
||||||
Connections {
|
Connections {
|
||||||
target: tdLibWrapper
|
target: tdLibWrapper
|
||||||
onAuthorizationStateChanged: {
|
onAuthorizationStateChanged: {
|
||||||
overviewPage.authorizationState = authorizationState;
|
handleAuthorizationState(false);
|
||||||
handleAuthorizationState();
|
|
||||||
}
|
}
|
||||||
onConnectionStateChanged: {
|
onConnectionStateChanged: {
|
||||||
overviewPage.connectionState = connectionState;
|
overviewPage.connectionState = connectionState;
|
||||||
|
@ -278,7 +275,7 @@ Page {
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: qsTr("About Fernschreiber")
|
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 {
|
MenuItem {
|
||||||
text: qsTr("Settings")
|
text: qsTr("Settings")
|
||||||
|
|
|
@ -31,6 +31,9 @@
|
||||||
class TDLibWrapper : public QObject
|
class TDLibWrapper : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(AuthorizationState authorizationState READ getAuthorizationState NOTIFY authorizationStateChanged)
|
||||||
|
Q_PROPERTY(QVariantMap userInformation READ getUserInformation NOTIFY ownUserUpdated)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface, QObject *parent = nullptr);
|
explicit TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface, QObject *parent = nullptr);
|
||||||
~TDLibWrapper();
|
~TDLibWrapper();
|
||||||
|
|
Loading…
Reference in a new issue