initial post stream added to profile view (issue #8)

This commit is contained in:
Morgan McMillian 2016-11-11 09:51:17 -08:00
parent 77f0f1e7d9
commit 40878e1059
5 changed files with 69 additions and 12 deletions

View file

@ -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: [

View file

@ -74,6 +74,8 @@ NavigationPane {
function viewProfile(userobj) {
var page = profilePage.createObject();
page.user = userobj
pnut.userStreamReceived.connect(page.loadThread)
pnut.getUserStream(userobj.id)
page.follow.connect(pnut.followUser)
page.unfollow.connect(pnut.unfollowUser)
page.block.connect(pnut.blockUser)

View file

@ -192,7 +192,7 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id)
qDebug() << "- onAuthorizedRequestReady";
qDebug() << "- id: " << id;
qDebug() << "- endpoint: " << endpoint;
// qDebug() << data;
qDebug() << data;
QVariant variant;
bb::data::JsonDataAccess jda;
@ -223,6 +223,11 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id)
emit threadReceived(variant.toMap()["data"].toList());
req_map.remove(id);
}
else if (endpoint == ":userstream")
{
emit userStreamReceived(variant.toMap()["data"].toList());
req_map.remove(id);
}
else if (endpoint == ":logout")
{
qDebug() << "Logout successful!";
@ -485,3 +490,11 @@ void Pnut::getPost(QString pid)
req_map[++req_id] = ":getpost:" + pid;
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);
}

View file

@ -85,6 +85,7 @@ public:
Q_INVOKABLE void logout();
Q_INVOKABLE void deletePost(QString pid);
Q_INVOKABLE void getPost(QString pid);
Q_INVOKABLE void getUserStream(QString uid);
public slots:
void onRequestReady(QByteArray data);
@ -103,6 +104,7 @@ Q_SIGNALS:
void muteSuccess(QVariantMap user);
void unmuteSuccess(QVariantMap user);
void postReceived(QVariantMap post);
void userStreamReceived(QVariantList stream);
private:
static const QString PNUT_API_ROOT;

View file

@ -103,32 +103,32 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/ProfilePage.qml" line="179"/>
<location filename="../assets/ProfilePage.qml" line="219"/>
<source>Unfollow</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/ProfilePage.qml" line="179"/>
<location filename="../assets/ProfilePage.qml" line="219"/>
<source>Follow</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/ProfilePage.qml" line="192"/>
<location filename="../assets/ProfilePage.qml" line="232"/>
<source>Unmute</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/ProfilePage.qml" line="192"/>
<location filename="../assets/ProfilePage.qml" line="232"/>
<source>Mute</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/ProfilePage.qml" line="205"/>
<location filename="../assets/ProfilePage.qml" line="245"/>
<source>Unblock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/ProfilePage.qml" line="205"/>
<location filename="../assets/ProfilePage.qml" line="245"/>
<source>Block</source>
<translation type="unfinished"></translation>
</message>
@ -172,22 +172,22 @@
<context>
<name>StreamTab</name>
<message>
<location filename="../assets/StreamTab.qml" line="137"/>
<location filename="../assets/StreamTab.qml" line="139"/>
<source>New Post</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="151"/>
<location filename="../assets/StreamTab.qml" line="153"/>
<source>To Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="179"/>
<location filename="../assets/StreamTab.qml" line="181"/>
<source>To Bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/StreamTab.qml" line="166"/>
<location filename="../assets/StreamTab.qml" line="168"/>
<source>Reload</source>
<translation type="unfinished"></translation>
</message>