💄 Try optimize post embed DX

This commit is contained in:
2025-08-06 13:38:49 +08:00
parent a52b09b787
commit 681934a0dc

View File

@@ -663,7 +663,7 @@ public partial class PostService(
); );
} }
private async Task LoadPollEmbed(Post post, Account? currentUser) private async Task LoadPostEmbed(Post post, Account? currentUser)
{ {
if (!post.Meta!.TryGetValue("embeds", out var value)) if (!post.Meta!.TryGetValue("embeds", out var value))
return; return;
@@ -681,7 +681,11 @@ public partial class PostService(
e.ContainsKey("Type") && ((JsonElement)e["Type"]).ToString() == "poll" e.ContainsKey("Type") && ((JsonElement)e["Type"]).ToString() == "poll"
); );
if (pollIndex < 0) return; if (pollIndex < 0)
{
post.Meta["embeds"] = embeds;
return;
}
var pollEmbed = embeds[pollIndex]; var pollEmbed = embeds[pollIndex];
try try
@@ -714,7 +718,7 @@ public partial class PostService(
var post in posts var post in posts
.Where(e => e.Meta is not null && e.Meta.ContainsKey("embeds")) .Where(e => e.Meta is not null && e.Meta.ContainsKey("embeds"))
) )
await LoadPollEmbed(post, currentUser); await LoadPostEmbed(post, currentUser);
if (truncate) if (truncate)
posts = TruncatePostContent(posts); posts = TruncatePostContent(posts);