Subject: [PATCH links] Only show tags associated with displayed links on organization pages if they've been filtered in any way (tags, search, etc.)

From: Peter Sanchez <[email-masked]>
Date: Thu, 1 May 2025 17:21:09 -0600

Changelog-changed: Only display associated tags with displayed links on
  organization pages when filtering is applied.
---
 core/routes.go | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/core/routes.go b/core/routes.go
index 18fde44..aa0c9f5 100644
--- a/core/routes.go
+++ b/core/routes.go
@@ -2128,13 +2128,14 @@ func (s *Service) OrgLinksList(c echo.Context) error {
 		currURL, navFlag, rssURL, followAction, slug string
 	)
 	org := &models.Organization{}
+	cloudType := model.CloudTypeLinks
 	if c.Path() != c.Echo().Reverse(s.RouteName("recent_link_list")) &&
 		c.Path() != c.Echo().Reverse(s.RouteName("recent_link_list_rss")) {
 		// This means that we want to see a specific org (private or businnes)
 		// and not all the recent links
 		slug = links.PullOrgSlug(c)
 		op.Var("slug", slug)
-		op.Var("cloudType", model.CloudTypeOrganization)
+		cloudType = model.CloudTypeOrganization
 		opts := &database.FilterOptions{
 			Filter: sq.And{
 				sq.Expr("o.slug = ?", slug),
@@ -2253,9 +2254,8 @@ func (s *Service) OrgLinksList(c echo.Context) error {
 	}
 
 	var (
-		tag,
-		excludeTag,
-		search string
+		tag, excludeTag, search string
+		isAltered               bool
 	)
 	queries := make(url.Values)
 
@@ -2263,19 +2263,27 @@ func (s *Service) OrgLinksList(c echo.Context) error {
 		tag = c.QueryParam("tag")
 		op.Var("tag", tag)
 		queries.Add("tag", tag)
+		isAltered = true
 	}
 	if c.QueryParam("exclude") != "" {
 		excludeTag = c.QueryParam("exclude")
 		op.Var("excludeTag", excludeTag)
 		queries.Add("exclude", excludeTag)
+		isAltered = true
 
 	}
 	if c.QueryParam("q") != "" {
 		search = c.QueryParam("q")
 		op.Var("search", search)
 		queries.Add("q", search)
+		isAltered = true
 	}
 
+	if isAltered && cloudType != model.CloudTypeLinks {
+		cloudType = model.CloudTypeLinks
+	}
+	op.Var("cloudType", cloudType)
+
 	orderDir := c.QueryParam("order")
 	if orderDir != "" && (orderDir == "DESC" || orderDir == "ASC") {
 		op.Var("order", orderDir)
-- 
2.47.2