From 74d8f46b08cfbe65a15f7dfe34c492019bfb4890 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Tue, 23 Nov 2021 16:08:54 +0900 Subject: [PATCH] Fixed activity page for anonymous access --- pages/activity/activity.go | 4 ++-- pages/activity/activity.pixy | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pages/activity/activity.go b/pages/activity/activity.go index b58a3403..21d70d60 100644 --- a/pages/activity/activity.go +++ b/pages/activity/activity.go @@ -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()) { diff --git a/pages/activity/activity.pixy b/pages/activity/activity.pixy index c622cf76..d9539843 100644 --- a/pages/activity/activity.pixy +++ b/pages/activity/activity.pixy @@ -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.