Received: from mail.netlandish.com (mail.netlandish.com [174.136.98.166])
	by code.netlandish.com (Postfix) with ESMTP id A921E2D7
	for <~netlandish/links-dev@lists.code.netlandish.com>; Thu, 01 May 2025 23:21:25 +0000 (UTC)
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.222.46; helo=mail-ua1-f46.google.com; envelope-from=peter@netlandish.com; receiver=<UNKNOWN> 
Authentication-Results: mail.netlandish.com;
	dkim=pass (1024-bit key; unprotected) header.d=netlandish.com header.i=@netlandish.com header.b=kTiYUO7K
Received: from mail-ua1-f46.google.com (mail-ua1-f46.google.com [209.85.222.46])
	by mail.netlandish.com (Postfix) with ESMTP id 028991D6463
	for <~netlandish/links-dev@lists.code.netlandish.com>; Thu, 01 May 2025 23:21:37 +0000 (UTC)
Received: by mail-ua1-f46.google.com with SMTP id a1e0cc1a2514c-86feb848764so346036241.0
        for <~netlandish/links-dev@lists.code.netlandish.com>; Thu, 01 May 2025 16:21:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=netlandish.com; s=google; t=1746141697; x=1746746497; darn=lists.code.netlandish.com;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to;
        bh=Em/bQVKmJUnWBmtegtZBOFMcbcceBCXcqQQgujCJ2zA=;
        b=kTiYUO7K07LaykykEr1+g50tkneksxskKY5Fgl62eG8jo9uqg0E/BCyWcJHD0BWDuN
         MXmUYM7nUU8Pc26ITn6OVd5/wgVHdavBGrkG+o6SMXhZttiDAufolQJAYS9xRydmaH1z
         BR/XrlsxMN0XJDuZgjkYC1NTU6vJpEbhnHdFk=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1746141697; x=1746746497;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=Em/bQVKmJUnWBmtegtZBOFMcbcceBCXcqQQgujCJ2zA=;
        b=huZ6WTmClGTbsY6PjuqtD4jdB9stylCsqzvpJwt3ZOEhXfIvV3SzB/PTC5AgWzRtLc
         viQ9vCwzXDCOmpASLN3M6WXo5dSRhoGtK6J1HorKRqWQeu+Bp3uCQEm7/ITVcPB52LA1
         RYBzbmwai7NlWLPxPhPW8uN59C9l2fOLGBPCRh4lI8Abufy/uGRLfV2PzBkZ8NVFzh2z
         Gwq0Oy0fdcLnn2s58mgQWPpB5Y+6hgpbjAur0q3NVYv6AJNnjr6GqWMhydpnBNtyxG0+
         G9gKtgfFEPOVwfhTu9wsCrw606VrvPOtR3JWYrI5Kd/lOj2O5brtgqFGgNjYnKMa/VUY
         V8DQ==
X-Gm-Message-State: AOJu0YwIVUyGkUwqCwxVGGcfKBAdkDHwyMkuQ/fiPRWd4aVQDaKPn8IF
	Ur1Pa0jbT3zFLHRCdXbVhwwwOsA+0to6EV7GYaZMVT7LaZ/MxDBm4bqDihj/ENZEbp73b+qGZkI
	W0PI=
X-Gm-Gg: ASbGncv0wKiQKGrsODbix1P7MDIhV7d00V5UqwtNauqpEKn8f2WNy82EFP5d9mA4p5s
	x4JO8bElyul4NXk0ntZ3NTHA+sv6DMVoulaKJGqsMOrmnoDfnbPabRfdxRfKJigAZ4/EHiXAYrp
	GZdPo4F6lZE72QxicO6FfmiS2t2pQc++pTF2CwGkOmS5ccmpdOU9+ZOwpzn5AlVvMeyCUnac/pB
	u6Em+sXxuGkCwEba48905OY+NzVi5LXB320XX/r8OWL1oDSlyiOq0lWDixAcnsjeVckAyfwaMij
	qo1tLGQmZ5joqH+K/aqg9wpY9TqJ0EWDD3jYurUHetXtQvWL+w==
X-Google-Smtp-Source: AGHT+IFZfrV4cL7Zpw3hsn1XwlFSQmCqsN86R4AUxnLlDYLCi8SwKzbNFpNI9yaSisOvvhYhvjwFWg==
X-Received: by 2002:a05:6102:330e:b0:4bb:d062:455 with SMTP id ada2fe7eead31-4dafb224177mr888165137.0.1746141696951;
        Thu, 01 May 2025 16:21:36 -0700 (PDT)
Received: from localhost ([2803:2d60:1118:5ee:db0b:ef:ef96:a2e0])
        by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-8780afeabf0sm68997241.2.2025.05.01.16.21.35
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 01 May 2025 16:21:36 -0700 (PDT)
From: Peter Sanchez <peter@netlandish.com>
To: ~netlandish/links-dev@lists.code.netlandish.com
Cc: Peter Sanchez <peter@netlandish.com>
Subject: [PATCH links] Only show tags associated with displayed links on organization pages if they've been filtered in any way (tags, search, etc.)
Date: Thu,  1 May 2025 17:21:09 -0600
Message-ID: <20250501232133.28605-1-peter@netlandish.com>
X-Mailer: git-send-email 2.47.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

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

