From 95d12a0a2d006122b4abd3acf4afb8696d30b889 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 12 Mar 2025 22:11:05 +0800 Subject: [PATCH] :bug: Fix the feed isn't sorted --- pkg/internal/services/feed.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/internal/services/feed.go b/pkg/internal/services/feed.go index de73414..8debacb 100644 --- a/pkg/internal/services/feed.go +++ b/pkg/internal/services/feed.go @@ -2,6 +2,7 @@ package services import ( "fmt" + "sort" "time" "git.solsynth.dev/hypernet/interactive/pkg/internal/database" @@ -45,6 +46,10 @@ func GetFeed(c *fiber.Ctx, limit int, user *uint, cursor *time.Time) ([]FeedEntr } feed = append(feed, fediPosts...) + sort.Slice(feed, func(i, j int) bool { + return feed[i].CreatedAt.After(feed[j].CreatedAt) + }) + return feed, nil }