From 7367f372c0d4c6def8f7003b56126e9705ae1286 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 5 Aug 2025 22:18:58 +0800 Subject: [PATCH] :bug: Fix post load poll, again... --- DysonNetwork.Sphere/Post/PostService.cs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/DysonNetwork.Sphere/Post/PostService.cs b/DysonNetwork.Sphere/Post/PostService.cs index d3e697d..1465ba8 100644 --- a/DysonNetwork.Sphere/Post/PostService.cs +++ b/DysonNetwork.Sphere/Post/PostService.cs @@ -675,29 +675,21 @@ public partial class PostService( }; if (embeds is null) return; - + // Find the index of the poll embed first var pollIndex = embeds.FindIndex(e => - e.ContainsKey("Type") && (string)e["Type"] == "poll"); + e.ContainsKey("Type") && ((JsonElement)e["Type"]).ToString() == "poll"); if (pollIndex < 0) return; var pollEmbed = embeds[pollIndex]; try { - var pollId = pollEmbed["Id"] switch - { - Guid g => g, - string s when !string.IsNullOrEmpty(s) => Guid.Parse(s), - _ => default(Guid?) - }; + var pollId = Guid.Parse(((JsonElement)pollEmbed["Id"]).ToString()); - if (pollId.HasValue) - { - var currentUserId = currentUser is not null ? Guid.Parse(currentUser.Id) : (Guid?)null; - var updatedPoll = await polls.LoadPollEmbed(pollId.Value, currentUserId); - embeds[pollIndex] = updatedPoll.ToDictionary(); - } + var currentUserId = currentUser is not null ? Guid.Parse(currentUser.Id) : (Guid?)null; + var updatedPoll = await polls.LoadPollEmbed(pollId, currentUserId); + embeds[pollIndex] = updatedPoll.ToDictionary(); } catch (Exception ex) {