Marking views

This commit is contained in:
2025-06-19 23:54:25 +08:00
parent eb1c283971
commit cfa63c7c93
6 changed files with 130 additions and 1 deletions

View File

@ -69,9 +69,14 @@ public class ActivityService(AppDatabase db, PublisherService pub, RelationshipS
var postsId = posts.Select(e => e.Id).ToList();
var reactionMaps = await ps.GetPostReactionMapBatch(postsId);
foreach (var post in posts)
{
post.ReactionsCount =
reactionMaps.TryGetValue(post.Id, out var count) ? count : new Dictionary<string, int>();
// Track view for each post in the feed
await ps.IncreaseViewCount(post.Id, currentUser.Id.ToString());
}
// Formatting data
foreach (var post in posts)
activities.Add(post.ToActivity());