Activity page shows create events only
This commit is contained in:
parent
f1ccc6c0c6
commit
b13b337990
@ -61,3 +61,16 @@ func StreamActivityCreates() <-chan *ActivityCreate {
|
|||||||
|
|
||||||
return channel
|
return channel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FilterActivityCreates filters all ActivityCreates by a custom function.
|
||||||
|
func FilterActivityCreates(filter func(Activity) bool) []Activity {
|
||||||
|
var filtered []Activity
|
||||||
|
|
||||||
|
for obj := range StreamActivityCreates() {
|
||||||
|
if filter(obj) {
|
||||||
|
filtered = append(filtered, obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filtered
|
||||||
|
}
|
||||||
|
@ -56,6 +56,11 @@ func (post *Post) GetParentID() string {
|
|||||||
return post.ParentID
|
return post.ParentID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetParentType returns the object type of the parent.
|
||||||
|
func (post *Post) GetParentType() string {
|
||||||
|
return post.ParentType
|
||||||
|
}
|
||||||
|
|
||||||
// SetParent sets a new parent.
|
// SetParent sets a new parent.
|
||||||
func (post *Post) SetParent(newParent PostParent) {
|
func (post *Post) SetParent(newParent PostParent) {
|
||||||
// Remove from old parent
|
// Remove from old parent
|
||||||
|
@ -23,6 +23,7 @@ type Postable interface {
|
|||||||
GetText() string
|
GetText() string
|
||||||
GetCreated() string
|
GetCreated() string
|
||||||
GetParentID() string
|
GetParentID() string
|
||||||
|
GetParentType() string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToPostables converts a slice of specific types to a slice of generic postables.
|
// ToPostables converts a slice of specific types to a slice of generic postables.
|
||||||
|
@ -54,6 +54,11 @@ func (thread *Thread) GetParentID() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetParentType always returns an empty string for threads.
|
||||||
|
func (thread *Thread) GetParentType() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// TypeName returns the type name.
|
// TypeName returns the type name.
|
||||||
func (thread *Thread) TypeName() string {
|
func (thread *Thread) TypeName() string {
|
||||||
return "Thread"
|
return "Thread"
|
||||||
|
@ -28,7 +28,7 @@ func fetchActivities(user *arn.User, followedOnly bool) []arn.Activity {
|
|||||||
followedUserIDs = user.Follows().Items
|
followedUserIDs = user.Follows().Items
|
||||||
}
|
}
|
||||||
|
|
||||||
activities := arn.FilterActivities(func(activity arn.Activity) bool {
|
activities := arn.FilterActivityCreates(func(activity arn.Activity) bool {
|
||||||
if followedOnly && !arn.Contains(followedUserIDs, activity.GetCreatedBy()) {
|
if followedOnly && !arn.Contains(followedUserIDs, activity.GetCreatedBy()) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -37,7 +37,6 @@ func fetchActivities(user *arn.User, followedOnly bool) []arn.Activity {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if activity.TypeName() == "ActivityCreate" {
|
|
||||||
obj := activity.(*arn.ActivityCreate).Object()
|
obj := activity.(*arn.ActivityCreate).Object()
|
||||||
|
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
@ -46,13 +45,6 @@ func fetchActivities(user *arn.User, followedOnly bool) []arn.Activity {
|
|||||||
|
|
||||||
draft, isDraftable := obj.(arn.Draftable)
|
draft, isDraftable := obj.(arn.Draftable)
|
||||||
return !isDraftable || !draft.GetIsDraft()
|
return !isDraftable || !draft.GetIsDraft()
|
||||||
}
|
|
||||||
|
|
||||||
if activity.TypeName() == "ActivityConsumeAnime" {
|
|
||||||
return activity.(*arn.ActivityConsumeAnime).Anime() != nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
})
|
})
|
||||||
|
|
||||||
arn.SortActivitiesLatestFirst(activities)
|
arn.SortActivitiesLatestFirst(activities)
|
||||||
|
@ -66,13 +66,15 @@ component ActivityConsumeAnimeText(activity *arn.ActivityConsumeAnime, user *arn
|
|||||||
span= fmt.Sprintf(" episode %d.", activity.ToEpisode)
|
span= fmt.Sprintf(" episode %d.", activity.ToEpisode)
|
||||||
|
|
||||||
component ActivityCreateMeta(activity *arn.ActivityCreate, user *arn.User)
|
component ActivityCreateMeta(activity *arn.ActivityCreate, user *arn.User)
|
||||||
span in
|
|
||||||
|
|
||||||
if activity.ObjectType == "Post"
|
if activity.ObjectType == "Post"
|
||||||
|
if activity.Postable().GetParentType() != "User" || activity.Postable().GetParentID() != activity.CreatedBy
|
||||||
|
span in
|
||||||
a(href=activity.Postable().Parent().Link())= activity.Postable().Parent().TitleByUser(user)
|
a(href=activity.Postable().Parent().Link())= activity.Postable().Parent().TitleByUser(user)
|
||||||
else if activity.ObjectType == "Thread"
|
else if activity.ObjectType == "Thread"
|
||||||
|
span in
|
||||||
a(href=activity.Postable().Link())= activity.Postable().TitleByUser(user)
|
a(href=activity.Postable().Link())= activity.Postable().TitleByUser(user)
|
||||||
else if activity.ObjectType == "AMV" || activity.ObjectType == "SoundTrack" || activity.ObjectType == "Quote"
|
else if activity.ObjectType == "AMV" || activity.ObjectType == "SoundTrack" || activity.ObjectType == "Quote"
|
||||||
|
span in
|
||||||
a(href=activity.Object().(arn.PostParent).Link())= activity.Object().(arn.PostParent).TitleByUser(user)
|
a(href=activity.Object().(arn.PostParent).Link())= activity.Object().(arn.PostParent).TitleByUser(user)
|
||||||
|
|
||||||
component ActivityCreateText(activity *arn.ActivityCreate, user *arn.User)
|
component ActivityCreateText(activity *arn.ActivityCreate, user *arn.User)
|
||||||
|
Loading…
Reference in New Issue
Block a user