Skip to content

Commit 61ce395

Browse files
committed
revert: use previous removeDuplicates to keep entry tag order
Refs: 863a5b3
1 parent 4a77e93 commit 61ce395

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

internal/storage/entry.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"errors"
99
"fmt"
1010
"log/slog"
11-
"slices"
1211
"strings"
1312
"time"
1413

@@ -612,9 +611,18 @@ func (s *Storage) UnshareEntry(userID int64, entryID int64) (err error) {
612611
return
613612
}
614613

615-
func removeDuplicates(l []string) []string {
616-
slices.Sort(l)
617-
return slices.Compact(l)
614+
// removeDuplicate removes duplicate entries from a slice while keeping order.
615+
// Some feeds expect tags to be shown in order, so we preserve it rather than sort.
616+
func removeDuplicates[T string | int](sliceList []T) []T {
617+
allKeys := make(map[T]bool)
618+
list := []T{}
619+
for _, item := range sliceList {
620+
if _, value := allKeys[item]; !value {
621+
allKeys[item] = true
622+
list = append(list, item)
623+
}
624+
}
625+
return list
618626
}
619627

620628
func removeEmpty(l []string) []string {

0 commit comments

Comments
 (0)