mirror of
https://github.com/muesli/telephant
synced 2024-11-22 19:33:06 +00:00
(Un)follow other users from the AccountPopup
This commit is contained in:
parent
ba045960a0
commit
1acbf8bfe3
4 changed files with 45 additions and 2 deletions
|
@ -164,6 +164,18 @@ func (mod *Account) Unlike(id string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Follow follows another user
|
||||
func (mod *Account) Follow(id string) error {
|
||||
_, err := mod.client.AccountFollow(context.Background(), mastodon.ID(id))
|
||||
return err
|
||||
}
|
||||
|
||||
// Unfollow unfollows another user
|
||||
func (mod *Account) Unfollow(id string) error {
|
||||
_, err := mod.client.AccountUnfollow(context.Background(), mastodon.ID(id))
|
||||
return err
|
||||
}
|
||||
|
||||
// LoadConversation loads a message conversation
|
||||
func (mod *Account) LoadConversation(id string) ([]accounts.MessageEvent, error) {
|
||||
var r []accounts.MessageEvent
|
||||
|
|
|
@ -17,6 +17,7 @@ type UIBridge struct {
|
|||
_ func(id string) `slot:"unshareButton"`
|
||||
_ func(id string) `slot:"likeButton"`
|
||||
_ func(id string) `slot:"unlikeButton"`
|
||||
_ func(id string, follow bool) `slot:"followButton"`
|
||||
_ func(id string) `slot:"loadConversation"`
|
||||
_ func(id string) `slot:"loadAccount"`
|
||||
|
||||
|
@ -91,6 +92,7 @@ func setupQmlBridges() {
|
|||
uiBridge.ConnectUnshareButton(unshare)
|
||||
uiBridge.ConnectLikeButton(like)
|
||||
uiBridge.ConnectUnlikeButton(unlike)
|
||||
uiBridge.ConnectFollowButton(follow)
|
||||
uiBridge.ConnectLoadConversation(loadConversation)
|
||||
uiBridge.ConnectLoadAccount(loadAccount)
|
||||
|
||||
|
|
19
chirp.go
19
chirp.go
|
@ -92,6 +92,25 @@ func unlike(id string) {
|
|||
}
|
||||
}
|
||||
|
||||
// follow changes the relationship to another user
|
||||
func follow(id string, follow bool) {
|
||||
if follow {
|
||||
log.Println("Following:", id)
|
||||
if err := tc.Follow(id); err != nil {
|
||||
log.Println("Error following user:", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
log.Println("Unfollowing:", id)
|
||||
if err := tc.Unfollow(id); err != nil {
|
||||
log.Println("Error unfollowing user:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
profileBridge.SetFollowing(follow)
|
||||
}
|
||||
|
||||
// loadConversation loads a message thread
|
||||
func loadConversation(id string) {
|
||||
log.Println("Loading conversation:", id)
|
||||
|
|
|
@ -32,19 +32,29 @@ ColumnLayout {
|
|||
Layout.fillWidth: true
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
text: profile.name
|
||||
font.pixelSize: 16
|
||||
font.bold: true
|
||||
elide: Label.ElideRight
|
||||
}
|
||||
Label {
|
||||
text: profile.username
|
||||
text: profile.username + (profile.followedBy ? " (follows you)" : "")
|
||||
font.pixelSize: 16
|
||||
opacity: 0.7
|
||||
elide: Label.ElideRight
|
||||
}
|
||||
}
|
||||
Button {
|
||||
id: followButton
|
||||
Layout.alignment: Qt.AlignBottom | Qt.AlignRight
|
||||
visible: profile.profileID != accountBridge.profileID
|
||||
highlighted: true
|
||||
text: profile.following ? qsTr("Unfollow") : qsTr("Follow")
|
||||
|
||||
onClicked: {
|
||||
uiBridge.followButton(profile.profileID, !profile.following)
|
||||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
|
Loading…
Reference in a new issue