Fixed activity page for anonymous access

This commit is contained in:
Eduard Urbach 2021-11-23 16:08:54 +09:00
parent 0f5f18db0c
commit 74d8f46b08
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
2 changed files with 12 additions and 11 deletions

View File

@ -21,7 +21,7 @@ func Watch(ctx aero.Context) error {
// fetchCreateActivities filters the activities by the given filters.
func fetchCreateActivities(user *arn.User) []arn.Activity {
followedOnly := user.Settings().Activity.ShowFollowedOnly
followedOnly := user != nil && user.Settings().Activity.ShowFollowedOnly
activities := arn.FilterActivityCreates(func(activity arn.Activity) bool {
if followedOnly && user != nil && !user.IsFollowing(activity.GetCreatedBy()) {
@ -48,7 +48,7 @@ func fetchCreateActivities(user *arn.User) []arn.Activity {
// fetchConsumeActivities filters the consume activities by the given filters.
func fetchConsumeActivities(user *arn.User) []arn.Activity {
followedOnly := user.Settings().Activity.ShowFollowedOnly
followedOnly := user != nil && user.Settings().Activity.ShowFollowedOnly
activities := arn.FilterActivitiesConsumeAnime(func(activity arn.Activity) bool {
if followedOnly && user != nil && !user.IsFollowing(activity.GetCreatedBy()) {

View File

@ -5,15 +5,16 @@ component ActivityFeed(entries []arn.Activity, nextIndex int, user *arn.User)
Tab("Posts", "comment", "/activity")
Tab("Watch", "eye", "/activity/watch")
.corner-buttons(data-api="/api/settings/" + user.ID)
if user.Settings().Activity.ShowFollowedOnly
button.action(id="Activity.ShowFollowedOnly", data-action="disable", data-trigger="click", data-field="Activity.ShowFollowedOnly", title="Followed only")
Icon("toggle-on")
span Followed
else
button.action(id="Activity.ShowFollowedOnly", data-action="enable", data-trigger="click", data-field="Activity.ShowFollowedOnly", title="Followed only")
Icon("toggle-off")
span Followed
if user != nil
.corner-buttons(data-api="/api/settings/" + user.ID)
if user.Settings().Activity.ShowFollowedOnly
button.action(id="Activity.ShowFollowedOnly", data-action="disable", data-trigger="click", data-field="Activity.ShowFollowedOnly", title="Followed only")
Icon("toggle-on")
span Followed
else
button.action(id="Activity.ShowFollowedOnly", data-action="enable", data-trigger="click", data-field="Activity.ShowFollowedOnly", title="Followed only")
Icon("toggle-off")
span Followed
if len(entries) == 0
p.no-data.mountable No activity here.