fix archived counts on filtering - href - simple bookmark manager in go/cgi
 (HTM) git clone https://git.drkhsh.at/href.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit d34aa97c005bfd9bc9b963a49962c1b80c971a79
 (DIR) parent 0ba58b154b045f84d13f22961ca2802d4453c2b5
 (HTM) Author: drkhsh <me@drkhsh.at>
       Date:   Fri, 15 Aug 2025 17:47:13 +0200
       
       fix archived counts on filtering
       
       Diffstat:
         M main.go                             |      11 ++++++++++-
       
       1 file changed, 10 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/main.go b/main.go
       @@ -99,13 +99,14 @@ func collectAllTags(urls []Entry) []string {
        }
        
        func handleSearch(w http.ResponseWriter, r *http.Request) {
       -        urls, archived, err := loadUrls()
       +        urls, _, err := loadUrls()
                if err != nil {
                        http.Error(w, "Internal Server Error", http.StatusInternalServerError)
                        return
                }
                query := r.URL.Query().Get("q")
        
       +        archived := 0
                var result []Entry
                query = strings.ToLower(query)
                for _, e := range urls {
       @@ -113,6 +114,9 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
                                strings.Contains(strings.ToLower(e.URL), query) ||
                                strings.Contains(strings.ToLower(e.Date), query) ||
                                tagsContain(e.Tags, query) {
       +                        if e.Archived {
       +                                archived++
       +                        }
                                result = append(result, e)
                        }
                }
       @@ -154,14 +158,19 @@ func handleList(w http.ResponseWriter, r *http.Request) {
                tagFilter := r.URL.Query().Get("tag")
        
                if tagFilter != "" {
       +                archived = 0
                        var filtered []Entry
                        for _, b := range urls {
                                for _, tag := range b.Tags {
                                        if strings.TrimSpace(tag) == tagFilter {
                                                filtered = append(filtered, b)
       +                                        if b.Archived {
       +                                                archived++
       +                                        }
                                                break
                                        }
                                }
       +
                        }
                        urls = filtered
                }