mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Add function to check if a comment is liked by the logged-in user
This commit is contained in:
parent
28070bd32d
commit
ead1db2be8
1 changed files with 10 additions and 0 deletions
10
comment.go
10
comment.go
|
|
@ -143,6 +143,16 @@ func (c *Comment) Like() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Liked returns if the user has liked the comment.
|
||||
func (c *Comment) Liked() bool {
|
||||
for _, flag := range c.Flags {
|
||||
if flag == "liked" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// RemoveLike removes the like from the comment. Works only if the user has liked it.
|
||||
func (c *Comment) RemoveLike() error {
|
||||
if err := c.unVote("like", "liked"); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue