Started working on activity likes
This commit is contained in:
parent
7fa0caac78
commit
1bd572cf3c
@ -26,7 +26,7 @@ component ActivitiesScrollable(entries []arn.Activity, user *arn.User)
|
||||
Activity(entry, user)
|
||||
|
||||
component Activity(activity arn.Activity, user *arn.User)
|
||||
.activity.post-parent.mountable(id=fmt.Sprintf("activity-%s", activity.GetID()))
|
||||
.activity.post-parent.mountable(id=fmt.Sprintf("activity-%s", activity.GetID()), data-api=utils.ActivityAPILink(activity))
|
||||
.post-author
|
||||
Avatar(activity.Creator())
|
||||
.post-content
|
||||
@ -37,8 +37,16 @@ component Activity(activity arn.Activity, user *arn.User)
|
||||
else if activity.TypeName() == "ActivityConsumeAnime"
|
||||
ActivityConsumeAnimeTitle(activity.(*arn.ActivityConsumeAnime), user)
|
||||
|
||||
if user != nil && user.ID == activity.GetCreatedBy() && activity.TypeName() == "ActivityConsumeAnime"
|
||||
button.activity-action.tip.action(data-action="deleteObject", data-trigger="click", aria-label="Delete", data-return-path="/activity", data-confirm-type="activity", data-api=fmt.Sprintf("/api/%s/%s", strings.ToLower(activity.TypeName()), activity.GetID()))
|
||||
if user != nil
|
||||
//- button.activity-action.tip.action(data-action="like", data-trigger="click", aria-label="Like")
|
||||
//- Icon("heart")
|
||||
//- if activity.TypeName() == "ActivityCreate"
|
||||
//- span= activity.(*arn.ActivityCreate).Object().CountLikes()
|
||||
//- else
|
||||
//- span= len(activity.(*arn.ActivityConsumeAnime).Likes)
|
||||
|
||||
if user.ID == activity.GetCreatedBy() && activity.TypeName() == "ActivityConsumeAnime"
|
||||
button.activity-action.tip.action(data-action="deleteObject", data-trigger="click", aria-label="Delete", data-return-path="/activity", data-confirm-type="activity")
|
||||
RawIcon("trash")
|
||||
|
||||
.activity-date.utc-date(data-date=activity.GetCreated())
|
||||
|
@ -50,6 +50,18 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
||||
each genre in topGenres
|
||||
a.anime-genre.mountable(href="/genre/" + strings.ToLower(genre), data-mountable-type="genre")= genre
|
||||
|
||||
//- Friends
|
||||
.profile-section.profile-section-friends
|
||||
h3.profile-column-header.mountable(data-mountable-type="extra") Friends
|
||||
|
||||
if len(friends) == 0
|
||||
p.no-data.mountable(data-mountable-type="extra") Nothing here yet.
|
||||
else
|
||||
.profile-friends.mountable(data-mountable-type="extra")
|
||||
each friend in friends
|
||||
.profile-friend.mountable(data-mountable-type="friend")
|
||||
Avatar(friend)
|
||||
|
||||
//- Activity
|
||||
.profile-section.profile-section-activity
|
||||
h3.profile-column-header.mountable(data-mountable-type="extra") Activity
|
||||
@ -68,18 +80,6 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
|
||||
if day == 2
|
||||
.spacer-box
|
||||
|
||||
//- Friends
|
||||
.profile-section
|
||||
h3.profile-column-header.mountable(data-mountable-type="extra") Friends
|
||||
|
||||
if len(friends) == 0
|
||||
p.no-data.mountable(data-mountable-type="extra") Nothing here yet.
|
||||
else
|
||||
.profile-friends.mountable(data-mountable-type="extra")
|
||||
each friend in friends
|
||||
.profile-friend.mountable(data-mountable-type="friend")
|
||||
Avatar(friend)
|
||||
|
||||
component ProfileHeader(viewUser *arn.User, user *arn.User, uri string)
|
||||
ProfileHead(viewUser, user, uri)
|
||||
|
||||
|
22
utils/ActivityLink.go
Normal file
22
utils/ActivityLink.go
Normal file
@ -0,0 +1,22 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/animenotifier/arn"
|
||||
)
|
||||
|
||||
// ActivityAPILink returns the API link for any activity.
|
||||
func ActivityAPILink(activity arn.Activity) string {
|
||||
id := activity.GetID()
|
||||
typeName := activity.TypeName()
|
||||
|
||||
if activity.TypeName() == "ActivityCreate" {
|
||||
created := activity.(*arn.ActivityCreate)
|
||||
typeName = created.ObjectType
|
||||
id = created.ObjectID
|
||||
}
|
||||
|
||||
return fmt.Sprintf("/api/%s/%s", strings.ToLower(typeName), id)
|
||||
}
|
Loading…
Reference in New Issue
Block a user