user interactions follow, block, mute, and fixed scroll on refresh closing

issue #1
This commit is contained in:
Morgan McMillian 2016-10-21 08:16:10 -07:00
parent f2edbba4cf
commit 0b42349f09
11 changed files with 168 additions and 18 deletions

View file

@ -1,5 +1,7 @@
1 1
31 34
icons/bell-slash.png
icons/bell.png
icons/comments.png icons/comments.png
icons/default_cover.png icons/default_cover.png
icons/globe.png icons/globe.png
@ -16,6 +18,7 @@ icons/ic_to_bottom.png
icons/ic_to_top.png icons/ic_to_top.png
icons/laughing_man.png icons/laughing_man.png
icons/messages.png icons/messages.png
icons/minus-circle.png
icons/quote-left.png icons/quote-left.png
icons/refresh.png icons/refresh.png
icons/retweet.png icons/retweet.png

View file

@ -8,6 +8,10 @@ Page {
signal follow(string uid) signal follow(string uid)
signal unfollow(string uid) signal unfollow(string uid)
signal block(string uid)
signal unblock(string uid)
signal mute(string uid)
signal unmute(string uid)
Container { Container {
Container { Container {
@ -153,7 +157,31 @@ Page {
follow(user.id) follow(user.id)
} }
} }
imageSource: (user.you_follow) ? "asset:///icons/ic_cancel.png" : "asset:///icons/ic_add.png" imageSource: (user.you_follow) ? "asset:///icons/minus-circle.png" : "asset:///icons/ic_add.png"
},
ActionItem {
title: (user.you_muted) ? qsTr("Unmute") : qsTr("Mute")
ActionBar.placement: ActionBarPlacement.InOverflow
onTriggered: {
if (user.you_muted) {
unmute(user.id)
} else {
mute(user.id)
}
}
imageSource: (user.you_muted) ? "asset:///icons/bell.png" : "asset:///icons/bell-slash.png"
},
ActionItem {
title: (user.you_blocked) ? qsTr("Unblock") : qsTr("Block")
ActionBar.placement: ActionBarPlacement.InOverflow
onTriggered: {
if (user.you_blocked) {
unblock(user.id)
} else {
block(user.id)
}
}
imageSource: "asset:///icons/ic_cancel.png"
} }
] ]
} }

View file

@ -26,6 +26,7 @@ NavigationPane {
property string stream_type property string stream_type
property string endpoint property string endpoint
property bool refreshpull: false
Page { Page {
Container { Container {
@ -36,6 +37,7 @@ NavigationPane {
} }
leadingVisual: RefreshItem { leadingVisual: RefreshItem {
onRefresh: { onRefresh: {
refreshpull = true
pnut.getStream(endpoint, Pnut.STREAM_NEWER); pnut.getStream(endpoint, Pnut.STREAM_NEWER);
} }
} }
@ -57,6 +59,10 @@ NavigationPane {
page.user = userobj page.user = userobj
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.unblock.connect(pnut.unblockUser)
page.mute.connect(pnut.muteUser)
page.unmute.connect(pnut.unmuteUser)
nav.push(page); nav.push(page);
} }
function sendReply(text, pid) { function sendReply(text, pid) {
@ -93,6 +99,7 @@ NavigationPane {
title: qsTr("Load Newer") title: qsTr("Load Newer")
ActionBar.placement: ActionBarPlacement.InOverflow ActionBar.placement: ActionBarPlacement.InOverflow
onTriggered: { onTriggered: {
refreshpull = true
pnut.getStream(endpoint, Pnut.STREAM_NEWER); pnut.getStream(endpoint, Pnut.STREAM_NEWER);
} }
imageSource: "asset:///icons/ic_to_top.png" imageSource: "asset:///icons/ic_to_top.png"
@ -112,6 +119,7 @@ NavigationPane {
title: qsTr("Load Older") title: qsTr("Load Older")
ActionBar.placement: ActionBarPlacement.InOverflow ActionBar.placement: ActionBarPlacement.InOverflow
onTriggered: { onTriggered: {
streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None);
pnut.getStream(endpoint, Pnut.STREAM_OLDER); pnut.getStream(endpoint, Pnut.STREAM_OLDER);
} }
imageSource: "asset:///icons/ic_to_bottom.png" imageSource: "asset:///icons/ic_to_bottom.png"
@ -160,7 +168,10 @@ NavigationPane {
break; break;
case Pnut.STREAM_NEWER: case Pnut.STREAM_NEWER:
postModel.insert(0, stream); postModel.insert(0, stream);
//streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None); if (refreshpull) {
refreshpull = false
streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None);
}
break; break;
} }
pnut.beforeId = postModel.value(postModel.size() - 1).id; pnut.beforeId = postModel.value(postModel.size() - 1).id;
@ -177,6 +188,26 @@ NavigationPane {
pnut.getStream(endpoint, Pnut.STREAM_OLDER); pnut.getStream(endpoint, Pnut.STREAM_OLDER);
timer.start(); timer.start();
} }
onFollowSuccess: update_user_page(user)
onUnfollowSuccess: update_user_page(user)
onBlockSuccess: update_user_page(user)
onUnblockSuccess: update_user_page(user)
onMuteSuccess: update_user_page(user)
onUnmuteSuccess: update_user_page(user)
function update_user_page(user) {
nav.top.user = user
postModel.clear()
pnut.beforeId = 0
pnut.sinceId = 0
pnut.getStream(endpoint, Pnut.STREAM_OLDER)
}
} }
] ]
onPopTransitionEnded: { onPopTransitionEnded: {

BIN
assets/icons/bell-slash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
assets/icons/bell.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -1 +1 @@
117 123

View file

@ -73,6 +73,8 @@ config_pri_assets {
$$quote($$BASEDIR/assets/RefreshItem.qml) \ $$quote($$BASEDIR/assets/RefreshItem.qml) \
$$quote($$BASEDIR/assets/StreamTab.qml) \ $$quote($$BASEDIR/assets/StreamTab.qml) \
$$quote($$BASEDIR/assets/ThreadPage.qml) \ $$quote($$BASEDIR/assets/ThreadPage.qml) \
$$quote($$BASEDIR/assets/icons/bell-slash.png) \
$$quote($$BASEDIR/assets/icons/bell.png) \
$$quote($$BASEDIR/assets/icons/comments.png) \ $$quote($$BASEDIR/assets/icons/comments.png) \
$$quote($$BASEDIR/assets/icons/default_cover.png) \ $$quote($$BASEDIR/assets/icons/default_cover.png) \
$$quote($$BASEDIR/assets/icons/globe.png) \ $$quote($$BASEDIR/assets/icons/globe.png) \
@ -89,6 +91,7 @@ config_pri_assets {
$$quote($$BASEDIR/assets/icons/ic_to_top.png) \ $$quote($$BASEDIR/assets/icons/ic_to_top.png) \
$$quote($$BASEDIR/assets/icons/laughing_man.png) \ $$quote($$BASEDIR/assets/icons/laughing_man.png) \
$$quote($$BASEDIR/assets/icons/messages.png) \ $$quote($$BASEDIR/assets/icons/messages.png) \
$$quote($$BASEDIR/assets/icons/minus-circle.png) \
$$quote($$BASEDIR/assets/icons/quote-left.png) \ $$quote($$BASEDIR/assets/icons/quote-left.png) \
$$quote($$BASEDIR/assets/icons/refresh.png) \ $$quote($$BASEDIR/assets/icons/refresh.png) \
$$quote($$BASEDIR/assets/icons/retweet.png) \ $$quote($$BASEDIR/assets/icons/retweet.png) \

View file

@ -225,13 +225,37 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id)
{ {
qDebug() << "Follow successful!"; qDebug() << "Follow successful!";
req_map.remove(id); req_map.remove(id);
emit followSuccess(data); emit followSuccess(variant.toMap()["data"].toMap());
} }
else if (endpoint == ":unfollow") else if (endpoint == ":unfollow")
{ {
qDebug() << "Unfollow successful!"; qDebug() << "Unfollow successful!";
req_map.remove(id); req_map.remove(id);
emit unfollowSuccess(data); emit unfollowSuccess(variant.toMap()["data"].toMap());
}
else if (endpoint == ":block")
{
qDebug() << "Block successful!";
req_map.remove(id);
emit blockSuccess(variant.toMap()["data"].toMap());
}
else if (endpoint == ":unblock")
{
qDebug() << "Unblock successful!";
req_map.remove(id);
emit unblockSuccess(variant.toMap()["data"].toMap());
}
else if (endpoint == ":mute")
{
qDebug() << "Mute successful!";
req_map.remove(id);
emit muteSuccess(variant.toMap()["data"].toMap());
}
else if (endpoint == ":unmute")
{
qDebug() << "Unmute successful!";
req_map.remove(id);
emit unmuteSuccess(variant.toMap()["data"].toMap());
} }
else { else {
qDebug() << "GOT SOMETHING NEW!"; qDebug() << "GOT SOMETHING NEW!";
@ -265,6 +289,7 @@ void Pnut::getStream(QString endpoint, Pnut::RequestType rtype)
{ {
QUrl url(PNUT_API_ROOT + endpoint); QUrl url(PNUT_API_ROOT + endpoint);
KQOAuthParameters parameters; KQOAuthParameters parameters;
parameters.insert("count", "50");
switch (rtype) switch (rtype)
{ {
case Pnut::STREAM_NEWER: case Pnut::STREAM_NEWER:
@ -388,3 +413,35 @@ void Pnut::unfollowUser(QString uid)
req_map[++req_id] = ":unfollow"; req_map[++req_id] = ":unfollow";
deleteRequest(url, parameters, req_id); deleteRequest(url, parameters, req_id);
} }
void Pnut::blockUser(QString uid)
{
QUrl url(PNUT_API_ROOT + "/users/" + uid + "/block");
KQOAuthParameters parameters;
req_map[++req_id] = ":block";
putRequest(url, parameters, req_id);
}
void Pnut::unblockUser(QString uid)
{
QUrl url(PNUT_API_ROOT + "/users/" + uid + "/block");
KQOAuthParameters parameters;
req_map[++req_id] = ":unblock";
deleteRequest(url, parameters, req_id);
}
void Pnut::muteUser(QString uid)
{
QUrl url(PNUT_API_ROOT + "/users/" + uid + "/mute");
KQOAuthParameters parameters;
req_map[++req_id] = ":mute";
putRequest(url, parameters, req_id);
}
void Pnut::unmuteUser(QString uid)
{
QUrl url(PNUT_API_ROOT + "/users/" + uid + "/mute");
KQOAuthParameters parameters;
req_map[++req_id] = ":unmute";
deleteRequest(url, parameters, req_id);
}

View file

@ -72,6 +72,10 @@ public:
Q_INVOKABLE void getUser(QString uid); Q_INVOKABLE void getUser(QString uid);
Q_INVOKABLE void followUser(QString uid); Q_INVOKABLE void followUser(QString uid);
Q_INVOKABLE void unfollowUser(QString uid); Q_INVOKABLE void unfollowUser(QString uid);
Q_INVOKABLE void blockUser(QString uid);
Q_INVOKABLE void unblockUser(QString uid);
Q_INVOKABLE void muteUser(QString uid);
Q_INVOKABLE void unmuteUser(QString uid);
Q_INVOKABLE void getUserInfo(); Q_INVOKABLE void getUserInfo();
Q_INVOKABLE void getThread(QString pid); Q_INVOKABLE void getThread(QString pid);
Q_INVOKABLE void setBookmark(QString pid); Q_INVOKABLE void setBookmark(QString pid);
@ -90,8 +94,12 @@ Q_SIGNALS:
void authorizationReceived(); void authorizationReceived();
void streamReceived(QVariantList stream, Pnut::RequestType rtype); void streamReceived(QVariantList stream, Pnut::RequestType rtype);
void threadReceived(QVariantList thread); void threadReceived(QVariantList thread);
void followSuccess(QByteArray user); void followSuccess(QVariantMap user);
void unfollowSuccess(QByteArray user); void unfollowSuccess(QVariantMap user);
void blockSuccess(QVariantMap user);
void unblockSuccess(QVariantMap user);
void muteSuccess(QVariantMap user);
void unmuteSuccess(QVariantMap user);
private: private:
static const QString PNUT_API_ROOT; static const QString PNUT_API_ROOT;

View file

@ -68,35 +68,55 @@
<context> <context>
<name>ProfilePage</name> <name>ProfilePage</name>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="93"/> <location filename="../assets/ProfilePage.qml" line="97"/>
<source>Following</source> <source>Following</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="106"/> <location filename="../assets/ProfilePage.qml" line="110"/>
<source>Followers</source> <source>Followers</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="119"/> <location filename="../assets/ProfilePage.qml" line="123"/>
<source>Posts</source> <source>Posts</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="132"/> <location filename="../assets/ProfilePage.qml" line="136"/>
<source>Bookmarks</source> <source>Bookmarks</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="147"/> <location filename="../assets/ProfilePage.qml" line="151"/>
<source>Unfollow</source> <source>Unfollow</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="147"/> <location filename="../assets/ProfilePage.qml" line="151"/>
<source>Follow</source> <source>Follow</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../assets/ProfilePage.qml" line="163"/>
<source>Unmute</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/ProfilePage.qml" line="163"/>
<source>Mute</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/ProfilePage.qml" line="175"/>
<source>Unblock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../assets/ProfilePage.qml" line="175"/>
<source>Block</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>RefreshItem</name> <name>RefreshItem</name>
@ -109,22 +129,22 @@
<context> <context>
<name>StreamTab</name> <name>StreamTab</name>
<message> <message>
<location filename="../assets/StreamTab.qml" line="86"/> <location filename="../assets/StreamTab.qml" line="90"/>
<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="95"/> <location filename="../assets/StreamTab.qml" line="99"/>
<source>Load Newer</source> <source>Load Newer</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/StreamTab.qml" line="103"/> <location filename="../assets/StreamTab.qml" line="107"/>
<source>Reload</source> <source>Reload</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/StreamTab.qml" line="114"/> <location filename="../assets/StreamTab.qml" line="118"/>
<source>Load Older</source> <source>Load Older</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>