From 0b42349f0958a9295b0e906706f87fc020583646 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Fri, 21 Oct 2016 08:16:10 -0700 Subject: [PATCH] user interactions follow, block, mute, and fixed scroll on refresh closing issue #1 --- assets/.assets.index | 5 ++- assets/ProfilePage.qml | 30 ++++++++++++++++- assets/StreamTab.qml | 33 +++++++++++++++++- assets/icons/bell-slash.png | Bin 0 -> 1429 bytes assets/icons/bell.png | Bin 0 -> 1134 bytes assets/icons/minus-circle.png | Bin 0 -> 1047 bytes buildnum | 2 +- config.pri | 3 ++ src/Pnut.cpp | 61 ++++++++++++++++++++++++++++++++-- src/Pnut.h | 12 +++++-- translations/Goober.ts | 40 ++++++++++++++++------ 11 files changed, 168 insertions(+), 18 deletions(-) create mode 100644 assets/icons/bell-slash.png create mode 100644 assets/icons/bell.png create mode 100644 assets/icons/minus-circle.png 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 0000000000000000000000000000000000000000..7bf41680aba13f1b06d97013449c057e97ccc0c9 GIT binary patch literal 1429 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wF4!XUI+Muxc(mnqaiRdLf}E(v`}E` zXDkWw3ubV5b|VeMN%D4gVd!9$^#F1>3p^r=85p>QL70(Y)*K0-AbW|YuPgflE>S)M zv$w4ce!z^Q?CIhdl5y|t%+ub?h63%+`SV#{9`vsM7;sR$$$!OBc2?U6)`Q;uL842V zIxbadIMtRuUy-YME5~f+%#^BEb5g!ffA78Njaetd=2=&#Xgj(jiC8n)@pX&Ty4DDO z@@z}Yi`QBaI63H`v}uRa!A9#a_bHOI9*21z6n(wWWy1T%DL|#1; z6*ZgxR?UTHlUd^zXjibrI!czXGVb0RoNAZxnX`#agWDneg4w6^8U0!t-ky&5Bh-I> zzA>ZyJO#r|mIs6NKmG3CA)d|qIBhRnb)^N<8-+7?@tzOBZx##aj=N~Rx!+d7Z-?{@zNe6GQ_*4DYxOUQBrI+<( zDz+^Ze=fGEmr9)%kJ;tiY=6tK|AzRZf5)#F*z7b~*_t#}@rK|U^NQJz)K*@w{M;FE9l$c)I$ztaD0e0sygF5?TNN literal 0 HcmV?d00001 diff --git a/assets/icons/bell.png b/assets/icons/bell.png new file mode 100644 index 0000000000000000000000000000000000000000..4dbefd75cc6b7470498eb9474f83e295ff1931c5 GIT binary patch literal 1134 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wF4!Xwg&iwxc(mnqaiTVLO|>n?=)aK zW-JNv3ubV5b|VeMN%D4gVd!9$^#F1>3p^r=85p>QL70(Y)*K0-AbW|YuPgflE>S)M zv1_jvv;p-PdAc};WZZjubGILpBSY)M%Cs$JAMdSLxS5HGaj}?P^LqtZUY2k5e1eS) z(_3%eoxh{d@BB}T%?<}!CQK@NkkWATyi(bIjWrF8ygfM!w7>3O*Dy1n&Lr8I_i4^H zY0e4eMQT^%7$P;e=Gg(;5g>sG(n|Knwk+=}zT|K1i?&HO%V((}!q*;RO+ za<>%ZGdr@pdzL!+{r{BvY?V%}(_O;n*Un^XDSbHm@_xk#^JR0_^DkH&n^I-Iuk8P) j-v;M>Jv=Ql?lJl>JS{WZvEwl?Kp8w;{an^LB{Ts5P_16X literal 0 HcmV?d00001 diff --git a/assets/icons/minus-circle.png b/assets/icons/minus-circle.png new file mode 100644 index 0000000000000000000000000000000000000000..1bc5cdc8088d6b96767ed979c3b1c3419ef76622 GIT binary patch literal 1047 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wF4!X$^v{sT>p=P(GZ|}2pn;pz6_WU z8B2ovf*Bm1-ADs*lDyqr7&=&GJ%Aj}0*}aI1_o|n5N2eUHAey{$X?><>&pIsOO($@ zwwPbK2dGEN)5S3)&3cwC>~pSnQj?hn-+p9PtZFc{vmFM96OsyX)_gXj6E z_nx~GtmX>H94`zz$}7L_*+bSkjW?I9c`igQd2iq~Z`OS!w;&sr6_2GkR+j!$@6fD# zdvQDG11W}ej8MX>fOo5vJnvS=OF|5r6nzEqgZT3}e;=tyxx&WjmB4+g#L-<(A*iYK zfkp1VO}dPF9USXUF+X{opZ=2ns`~=&m(@PI`ZX~#$jSco4JY|M*X(Dv z*_hS~pHMwh-})$?>E-ns0UPxneFN`dpuuP&QZ?!<=UIt=N`uYx%^A@mC~&Fvd0UjosfQbF ProfilePage - + Following - + Followers - + Posts - + Bookmarks - + Unfollow - + Follow + + + Unmute + + + + + Mute + + + + + Unblock + + + + + Block + + RefreshItem @@ -109,22 +129,22 @@ StreamTab - + New Post - + Load Newer - + Reload - + Load Older