fixed login with multiple tabs

This commit is contained in:
Morgan McMillian 2016-10-21 16:53:19 -07:00
parent 81b1874e6e
commit 80ad29bef0
7 changed files with 81 additions and 25 deletions

View file

@ -1,7 +1,7 @@
import bb.cascades 1.4
Sheet {
peekEnabled: false
// peekEnabled: false
signal login
Page {

View file

@ -28,6 +28,10 @@ NavigationPane {
property string endpoint
property int unread: -1
property bool refreshpull: false
property bool active
signal openLogin()
signal closeLogin()
Page {
Container {
@ -52,10 +56,15 @@ NavigationPane {
var page = threadPage.createObject();
pnut.threadReceived.connect(page.loadThread);
pnut.getThread(postModel.data(indexPath).thread_id);
page.follow.connect(pnut.followUser)
page.unfollow.connect(pnut.unfollowUser)
page.block.connect(pnut.blockUser)
page.unblock.connect(pnut.unblockUser)
page.mute.connect(pnut.muteUser)
page.unmute.connect(pnut.unmuteUser)
nav.push(page);
}
function viewProfile(userobj) {
console.log("narf: " + JSON.stringify(userobj))
var page = profilePage.createObject();
page.user = userobj
page.follow.connect(pnut.followUser)
@ -174,14 +183,8 @@ NavigationPane {
NewPostSheet {
id: newPostSheet
onSendPost: {
console.log("send: " + text);
pnut.sendPost(text);
}
},
LoginSheet {
id: loginSheet
onLogin: {
pnut.authorize();
console.log("send: " + text)
pnut.sendPost(text)
}
},
QTimer {
@ -217,14 +220,17 @@ NavigationPane {
}
onAuthorizationRequired: {
loginSheet.open();
console.log("__Got a auth required thingy")
openLogin()
timer.stop();
}
onAuthorizationReceived: {
loginSheet.close();
console.log("-- THIS --")
closeLogin()
pnut.getStream(endpoint, Pnut.STREAM_OLDER);
timer.start();
console.log("__Should be closed now")
}
onFollowSuccess: update_user_page(user)
@ -263,7 +269,7 @@ NavigationPane {
onCreationCompleted: {
switch (stream_type) {
case "Home":
endpoint = "/posts/streams/unified";
endpoint = "/posts/streams/unified"
break;
case "Global":
default:
@ -271,15 +277,20 @@ NavigationPane {
break;
}
if (_app.setting("access_token") && _app.setting("access_token").length > 0) {
pnut.getUserInfo();
pnut.getStream(endpoint, Pnut.STREAM_OLDER);
console.log("__I think I'm authenticated")
pnut.getUserInfo()
pnut.getStream(endpoint, Pnut.STREAM_OLDER)
timer.start();
} else {
loginSheet.open();
timer.stop();
console.log("__I am not authenticated yet")
openLogin()
timer.stop()
}
}
function login() {
pnut.authorize()
}
function logout() {
pnut.logout();
pnut.logout()
}
}

View file

@ -1,6 +1,14 @@
import bb.cascades 1.4
Page {
Page {
signal follow(string uid)
signal unfollow(string uid)
signal block(string uid)
signal unblock(string uid)
signal mute(string uid)
signal unmute(string uid)
Container {
ListView {
id: threadView
@ -19,6 +27,17 @@ Page {
function getUserName() {
return _app.setting("username")
}
function viewProfile(userobj) {
var page = profilePage.createObject();
page.user = userobj
page.follow.connect(follow)
page.unfollow.connect(unfollow)
page.block.connect(block)
page.unblock.connect(unblock)
page.mute.connect(mute)
page.unmute.connect(unmute)
nav.push(page);
}
}
}

View file

@ -47,6 +47,12 @@ TabbedPane {
delegate: Delegate {
StreamTab {
stream_type: "Home"
onOpenLogin: {
loginSheet.open()
}
onCloseLogin: {
loginSheet.close()
}
}
}
imageSource: "asset:///icons/home.png"
@ -62,6 +68,12 @@ TabbedPane {
StreamTab {
id: globalTab
stream_type: "Global"
onOpenLogin: {
loginSheet.open()
}
onCloseLogin: {
loginSheet.close()
}
}
}
imageSource: "asset:///icons/globe.png"
@ -70,4 +82,13 @@ TabbedPane {
}
}
attachedObjects: [
LoginSheet {
id: loginSheet
onLogin: {
activePane.login()
}
}
]
}

View file

@ -1 +1 @@
138
168

View file

@ -145,8 +145,13 @@ void Pnut::deleteRequest(QUrl url, KQOAuthParameters parameters, int id)
void Pnut::onAuthorizationReceived(QString token, QString verifier)
{
qDebug() << "--check check--";
qDebug() << oauthManager->lastError();
qDebug() << "token: " << token;
qDebug() << "verif: " << verifier;
switch (oauthManager->lastError())
{
case KQOAuthManager::RequestValidationError:
case KQOAuthManager::NoError:
qDebug() << "- authorization received -";
m_appSettings->setValue("access_token", token);

View file

@ -129,22 +129,22 @@
<context>
<name>StreamTab</name>
<message>
<location filename="../assets/StreamTab.qml" line="108"/>
<location filename="../assets/StreamTab.qml" line="117"/>
<source>New Post</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="117"/>
<location filename="../assets/StreamTab.qml" line="131"/>
<source>To Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="143"/>
<location filename="../assets/StreamTab.qml" line="157"/>
<source>To Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="132"/>
<location filename="../assets/StreamTab.qml" line="146"/>
<source>Reload</source>
<translation type="unfinished"></translation>
</message>
@ -162,7 +162,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/main.qml" line="60"/>
<location filename="../assets/main.qml" line="66"/>
<source>Global</source>
<translation type="unfinished"></translation>
</message>