diff --git a/assets/.assets.index b/assets/.assets.index index 32fa53d..48d7d0a 100644 --- a/assets/.assets.index +++ b/assets/.assets.index @@ -1,5 +1,7 @@ 1 -31 +34 +icons/bell-slash.png +icons/bell.png icons/comments.png icons/default_cover.png icons/globe.png @@ -16,6 +18,7 @@ icons/ic_to_bottom.png icons/ic_to_top.png icons/laughing_man.png icons/messages.png +icons/minus-circle.png icons/quote-left.png icons/refresh.png icons/retweet.png diff --git a/assets/ProfilePage.qml b/assets/ProfilePage.qml index 873a14c..0416dc2 100644 --- a/assets/ProfilePage.qml +++ b/assets/ProfilePage.qml @@ -8,6 +8,10 @@ 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 { Container { @@ -153,7 +157,31 @@ Page { 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" } ] } diff --git a/assets/StreamTab.qml b/assets/StreamTab.qml index 44ba7fa..4430e3c 100644 --- a/assets/StreamTab.qml +++ b/assets/StreamTab.qml @@ -26,6 +26,7 @@ NavigationPane { property string stream_type property string endpoint + property bool refreshpull: false Page { Container { @@ -36,6 +37,7 @@ NavigationPane { } leadingVisual: RefreshItem { onRefresh: { + refreshpull = true pnut.getStream(endpoint, Pnut.STREAM_NEWER); } } @@ -57,6 +59,10 @@ NavigationPane { page.user = userobj 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 sendReply(text, pid) { @@ -93,6 +99,7 @@ NavigationPane { title: qsTr("Load Newer") ActionBar.placement: ActionBarPlacement.InOverflow onTriggered: { + refreshpull = true pnut.getStream(endpoint, Pnut.STREAM_NEWER); } imageSource: "asset:///icons/ic_to_top.png" @@ -112,6 +119,7 @@ NavigationPane { title: qsTr("Load Older") ActionBar.placement: ActionBarPlacement.InOverflow onTriggered: { + streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None); pnut.getStream(endpoint, Pnut.STREAM_OLDER); } imageSource: "asset:///icons/ic_to_bottom.png" @@ -160,7 +168,10 @@ NavigationPane { break; case Pnut.STREAM_NEWER: postModel.insert(0, stream); - //streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None); + if (refreshpull) { + refreshpull = false + streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None); + } break; } pnut.beforeId = postModel.value(postModel.size() - 1).id; @@ -177,6 +188,26 @@ NavigationPane { pnut.getStream(endpoint, Pnut.STREAM_OLDER); 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: { diff --git a/assets/icons/bell-slash.png b/assets/icons/bell-slash.png new file mode 100644 index 0000000..7bf4168 Binary files /dev/null and b/assets/icons/bell-slash.png differ diff --git a/assets/icons/bell.png b/assets/icons/bell.png new file mode 100644 index 0000000..4dbefd7 Binary files /dev/null and b/assets/icons/bell.png differ diff --git a/assets/icons/minus-circle.png b/assets/icons/minus-circle.png new file mode 100644 index 0000000..1bc5cdc Binary files /dev/null and b/assets/icons/minus-circle.png differ diff --git a/buildnum b/buildnum index 1bda760..d800886 100644 --- a/buildnum +++ b/buildnum @@ -1 +1 @@ -117 \ No newline at end of file +123 \ No newline at end of file diff --git a/config.pri b/config.pri index 4d4df08..9b0c171 100644 --- a/config.pri +++ b/config.pri @@ -73,6 +73,8 @@ config_pri_assets { $$quote($$BASEDIR/assets/RefreshItem.qml) \ $$quote($$BASEDIR/assets/StreamTab.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/default_cover.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/laughing_man.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/refresh.png) \ $$quote($$BASEDIR/assets/icons/retweet.png) \ diff --git a/src/Pnut.cpp b/src/Pnut.cpp index 1157cc2..ac9bcf9 100644 --- a/src/Pnut.cpp +++ b/src/Pnut.cpp @@ -225,13 +225,37 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id) { qDebug() << "Follow successful!"; req_map.remove(id); - emit followSuccess(data); + emit followSuccess(variant.toMap()["data"].toMap()); } else if (endpoint == ":unfollow") { qDebug() << "Unfollow successful!"; 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 { qDebug() << "GOT SOMETHING NEW!"; @@ -265,6 +289,7 @@ void Pnut::getStream(QString endpoint, Pnut::RequestType rtype) { QUrl url(PNUT_API_ROOT + endpoint); KQOAuthParameters parameters; + parameters.insert("count", "50"); switch (rtype) { case Pnut::STREAM_NEWER: @@ -388,3 +413,35 @@ void Pnut::unfollowUser(QString uid) req_map[++req_id] = ":unfollow"; 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); +} diff --git a/src/Pnut.h b/src/Pnut.h index d53e436..17c2ed4 100644 --- a/src/Pnut.h +++ b/src/Pnut.h @@ -72,6 +72,10 @@ public: Q_INVOKABLE void getUser(QString uid); Q_INVOKABLE void followUser(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 getThread(QString pid); Q_INVOKABLE void setBookmark(QString pid); @@ -90,8 +94,12 @@ Q_SIGNALS: void authorizationReceived(); void streamReceived(QVariantList stream, Pnut::RequestType rtype); void threadReceived(QVariantList thread); - void followSuccess(QByteArray user); - void unfollowSuccess(QByteArray user); + void followSuccess(QVariantMap user); + void unfollowSuccess(QVariantMap user); + void blockSuccess(QVariantMap user); + void unblockSuccess(QVariantMap user); + void muteSuccess(QVariantMap user); + void unmuteSuccess(QVariantMap user); private: static const QString PNUT_API_ROOT; diff --git a/translations/Goober.ts b/translations/Goober.ts index 9b72508..09b32fb 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -68,35 +68,55 @@ ProfilePage - + Following - + Followers - + Posts - + Bookmarks - + Unfollow - + Follow + + + Unmute + + + + + Mute + + + + + Unblock + + + + + Block + + RefreshItem @@ -109,22 +129,22 @@ StreamTab - + New Post - + Load Newer - + Reload - + Load Older