attached follow/unfollow signals and cleaned up commented out code

This commit is contained in:
Morgan McMillian 2016-11-12 08:55:16 -08:00
parent c581ff985f
commit 358f0adddc
4 changed files with 26 additions and 116 deletions

View file

@ -200,8 +200,8 @@ Page {
text: qsTr("Following") text: qsTr("Following")
onClicked: { onClicked: {
var page = userListPage.createObject() var page = userListPage.createObject()
// page.follow.connect(pnut.followUser) pnut.followSuccess.connect(page.updateUser)
// page.unfollow.connect(pnut.unfollowUser) pnut.unfollowSuccess.connect(page.updateUser)
pnut.userListReceived.connect(page.loadThread) pnut.userListReceived.connect(page.loadThread)
pnut.getFollowing(user.id) pnut.getFollowing(user.id)
nav.push(page) nav.push(page)
@ -215,8 +215,8 @@ Page {
text: qsTr("Followers") text: qsTr("Followers")
onClicked: { onClicked: {
var page = userListPage.createObject() var page = userListPage.createObject()
// page.follow.connect(pnut.followUser) pnut.followSuccess.connect(page.updateUser)
// page.unfollow.connect(pnut.unfollowUser) pnut.unfollowSuccess.connect(page.updateUser)
pnut.userListReceived.connect(page.loadThread) pnut.userListReceived.connect(page.loadThread)
pnut.getFollowers(user.id) pnut.getFollowers(user.id)
nav.push(page) nav.push(page)
@ -224,79 +224,9 @@ Page {
} }
} }
} }
// SegmentedControl {
// Option {
// id: opt_posts
// text: qsTr("Posts")
// }
// Option {
// id: opt_following
// text: qsTr("Following")
// }
// Option {
// id: opt_followers
// text: qsTr("Followers")
// }
// onSelectedOptionChanged: {
// if (selectedOption == opt_posts) {
// threadModel.clear()
// getPosts(user.id)
// } else if (selectedOption == opt_following) {
// threadModel.clear()
// // do something
// } else if (selectedOption == opt_followers) {
// threadModel.clear()
// // do something
// }
// }
// }
// ListView {
// id: threadView
// //preferredHeight: threadModel.size()
// //preferredHeight: ( height of content row + content padding ) * count of entires in ListView
// dataModel: ArrayDataModel {
// id: threadModel
// }
// listItemComponents: [
// ListItemComponent {
// id: root
// PostItem {
// id: 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: [
ActionItem { ActionItem {
title: (user.you_follow) ? qsTr("Unfollow") : qsTr("Follow") title: (user.you_follow) ? qsTr("Unfollow") : qsTr("Follow")

View file

@ -54,9 +54,9 @@ Container {
text: (ListItemData.you_follow) ? qsTr("Unfollow") : qsTr("Follow") text: (ListItemData.you_follow) ? qsTr("Unfollow") : qsTr("Follow")
onClicked: { onClicked: {
if (ListItemData.you_follow) { if (ListItemData.you_follow) {
useritem.ListItem.view.unfollow(ListItemData.id) useritem.ListItem.view.unfollow(ListItemData)
} else { } else {
useritem.ListItem.view.follow(ListItemData.id) useritem.ListItem.view.follow(ListItemData)
} }
} }
} }

View file

@ -21,12 +21,7 @@ import bb.cascades 1.4
Page { Page {
signal follow(string uid) property variant updateUserObj
signal unfollow(string uid)
signal block(string uid)
signal unblock(string uid)
signal mute(string uid)
signal unmute(string uid)
Container { Container {
ListView { ListView {
@ -40,40 +35,25 @@ Page {
UserItem {} UserItem {}
} }
] ]
function follow(uid) { function follow(usero) {
pnut.followUser(uid) console.log("---> follow")
updateUserObj = usero
pnut.followUser(usero.id)
} }
function unfollow(uid) { function unfollow(usero) {
pnut.unfollowUser(uid) console.log("---> unfollow")
updateUserObj = usero
pnut.unfollowUser(usero.id)
} }
// 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) { function loadThread(data) {
listModel.append(data); listModel.append(data);
} }
function updateUser(userobj) {
console.log("---> updating entry " + listModel.indexOf(updateUserObj))
listModel.replace(listModel.indexOf(updateUserObj), userobj)
}
} }

View file

@ -106,32 +106,32 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="302"/> <location filename="../assets/ProfilePage.qml" line="232"/>
<source>Unfollow</source> <source>Unfollow</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="302"/> <location filename="../assets/ProfilePage.qml" line="232"/>
<source>Follow</source> <source>Follow</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="315"/> <location filename="../assets/ProfilePage.qml" line="245"/>
<source>Unmute</source> <source>Unmute</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="315"/> <location filename="../assets/ProfilePage.qml" line="245"/>
<source>Mute</source> <source>Mute</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="328"/> <location filename="../assets/ProfilePage.qml" line="258"/>
<source>Unblock</source> <source>Unblock</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../assets/ProfilePage.qml" line="328"/> <location filename="../assets/ProfilePage.qml" line="258"/>
<source>Block</source> <source>Block</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>