From 82a92ecc9a193285d234c270ca32c0396e70ee18 Mon Sep 17 00:00:00 2001 From: a <a@tuxpa.in> Date: Mon, 10 Feb 2025 14:28:49 -0600 Subject: [PATCH] remove dups --- src/components/commands/radio.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/commands/radio.go b/src/components/commands/radio.go index 06c0c9d..eb56fd6 100644 --- a/src/components/commands/radio.go +++ b/src/components/commands/radio.go @@ -27,7 +27,7 @@ func (c *Commander) GetRecomendationIdsForPrompt(ctx context.Context, prompt str if err != nil { return nil, err } - ids := []spotify.ID{} + isMap := map[spotify.ID]struct{}{} for _, v := range radioResp.Tracks { match, err := c.lb.MatchTrack(ctx, &v) if err != nil { @@ -41,9 +41,13 @@ func (c *Commander) GetRecomendationIdsForPrompt(ctx context.Context, prompt str if match.SpotifyId == "" { continue } - ids = append(ids, spotify.ID(match.SpotifyId)) + isMap[spotify.ID(match.SpotifyId)] = struct{}{} } - return ids, nil + keys := make([]spotify.ID, 0, len(isMap)) + for i := range isMap { + keys = append(keys, i) + } + return keys, nil } func (c *Commander) RadioFromPrompt(ctx context.Context, prompt string, mode string) error {