initial post stream added to profile view (issue #8)
This commit is contained in:
parent
77f0f1e7d9
commit
40878e1059
5 changed files with 69 additions and 12 deletions
|
@ -170,8 +170,48 @@ Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Divider {}
|
||||||
|
ListView {
|
||||||
|
id: threadView
|
||||||
|
dataModel: ArrayDataModel {
|
||||||
|
id: threadModel
|
||||||
|
}
|
||||||
|
listItemComponents: [
|
||||||
|
ListItemComponent {
|
||||||
|
id: root
|
||||||
|
PostItem {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
function sendReply(text, pid) {
|
||||||
|
pnut.sendReply(text, pid);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
function ccOnReply() {
|
||||||
|
if (_app.setting("cc") === "true") {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadThread(data) {
|
||||||
|
threadModel.append(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
actions: [
|
actions: [
|
||||||
|
|
|
@ -74,6 +74,8 @@ NavigationPane {
|
||||||
function viewProfile(userobj) {
|
function viewProfile(userobj) {
|
||||||
var page = profilePage.createObject();
|
var page = profilePage.createObject();
|
||||||
page.user = userobj
|
page.user = userobj
|
||||||
|
pnut.userStreamReceived.connect(page.loadThread)
|
||||||
|
pnut.getUserStream(userobj.id)
|
||||||
page.follow.connect(pnut.followUser)
|
page.follow.connect(pnut.followUser)
|
||||||
page.unfollow.connect(pnut.unfollowUser)
|
page.unfollow.connect(pnut.unfollowUser)
|
||||||
page.block.connect(pnut.blockUser)
|
page.block.connect(pnut.blockUser)
|
||||||
|
|
15
src/Pnut.cpp
15
src/Pnut.cpp
|
@ -192,7 +192,7 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id)
|
||||||
qDebug() << "- onAuthorizedRequestReady";
|
qDebug() << "- onAuthorizedRequestReady";
|
||||||
qDebug() << "- id: " << id;
|
qDebug() << "- id: " << id;
|
||||||
qDebug() << "- endpoint: " << endpoint;
|
qDebug() << "- endpoint: " << endpoint;
|
||||||
// qDebug() << data;
|
qDebug() << data;
|
||||||
|
|
||||||
QVariant variant;
|
QVariant variant;
|
||||||
bb::data::JsonDataAccess jda;
|
bb::data::JsonDataAccess jda;
|
||||||
|
@ -223,6 +223,11 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id)
|
||||||
emit threadReceived(variant.toMap()["data"].toList());
|
emit threadReceived(variant.toMap()["data"].toList());
|
||||||
req_map.remove(id);
|
req_map.remove(id);
|
||||||
}
|
}
|
||||||
|
else if (endpoint == ":userstream")
|
||||||
|
{
|
||||||
|
emit userStreamReceived(variant.toMap()["data"].toList());
|
||||||
|
req_map.remove(id);
|
||||||
|
}
|
||||||
else if (endpoint == ":logout")
|
else if (endpoint == ":logout")
|
||||||
{
|
{
|
||||||
qDebug() << "Logout successful!";
|
qDebug() << "Logout successful!";
|
||||||
|
@ -485,3 +490,11 @@ void Pnut::getPost(QString pid)
|
||||||
req_map[++req_id] = ":getpost:" + pid;
|
req_map[++req_id] = ":getpost:" + pid;
|
||||||
getRequest(url, parameters, req_id);
|
getRequest(url, parameters, req_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Pnut::getUserStream(QString uid)
|
||||||
|
{
|
||||||
|
QUrl url(PNUT_API_ROOT + "/users/" + uid + "/posts");
|
||||||
|
KQOAuthParameters parameters;
|
||||||
|
req_map[++req_id] = ":userstream";
|
||||||
|
getRequest(url, parameters, req_id);
|
||||||
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ public:
|
||||||
Q_INVOKABLE void logout();
|
Q_INVOKABLE void logout();
|
||||||
Q_INVOKABLE void deletePost(QString pid);
|
Q_INVOKABLE void deletePost(QString pid);
|
||||||
Q_INVOKABLE void getPost(QString pid);
|
Q_INVOKABLE void getPost(QString pid);
|
||||||
|
Q_INVOKABLE void getUserStream(QString uid);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onRequestReady(QByteArray data);
|
void onRequestReady(QByteArray data);
|
||||||
|
@ -103,6 +104,7 @@ Q_SIGNALS:
|
||||||
void muteSuccess(QVariantMap user);
|
void muteSuccess(QVariantMap user);
|
||||||
void unmuteSuccess(QVariantMap user);
|
void unmuteSuccess(QVariantMap user);
|
||||||
void postReceived(QVariantMap post);
|
void postReceived(QVariantMap post);
|
||||||
|
void userStreamReceived(QVariantList stream);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const QString PNUT_API_ROOT;
|
static const QString PNUT_API_ROOT;
|
||||||
|
|
|
@ -103,32 +103,32 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/ProfilePage.qml" line="179"/>
|
<location filename="../assets/ProfilePage.qml" line="219"/>
|
||||||
<source>Unfollow</source>
|
<source>Unfollow</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/ProfilePage.qml" line="179"/>
|
<location filename="../assets/ProfilePage.qml" line="219"/>
|
||||||
<source>Follow</source>
|
<source>Follow</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/ProfilePage.qml" line="192"/>
|
<location filename="../assets/ProfilePage.qml" line="232"/>
|
||||||
<source>Unmute</source>
|
<source>Unmute</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/ProfilePage.qml" line="192"/>
|
<location filename="../assets/ProfilePage.qml" line="232"/>
|
||||||
<source>Mute</source>
|
<source>Mute</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/ProfilePage.qml" line="205"/>
|
<location filename="../assets/ProfilePage.qml" line="245"/>
|
||||||
<source>Unblock</source>
|
<source>Unblock</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/ProfilePage.qml" line="205"/>
|
<location filename="../assets/ProfilePage.qml" line="245"/>
|
||||||
<source>Block</source>
|
<source>Block</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -172,22 +172,22 @@
|
||||||
<context>
|
<context>
|
||||||
<name>StreamTab</name>
|
<name>StreamTab</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/StreamTab.qml" line="137"/>
|
<location filename="../assets/StreamTab.qml" line="139"/>
|
||||||
<source>New Post</source>
|
<source>New Post</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/StreamTab.qml" line="151"/>
|
<location filename="../assets/StreamTab.qml" line="153"/>
|
||||||
<source>To Top</source>
|
<source>To Top</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/StreamTab.qml" line="179"/>
|
<location filename="../assets/StreamTab.qml" line="181"/>
|
||||||
<source>To Bottom</source>
|
<source>To Bottom</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../assets/StreamTab.qml" line="166"/>
|
<location filename="../assets/StreamTab.qml" line="168"/>
|
||||||
<source>Reload</source>
|
<source>Reload</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
Reference in a new issue