🐛 Fix post load poll, again...
This commit is contained in:
@@ -675,29 +675,21 @@ public partial class PostService(
|
|||||||
};
|
};
|
||||||
if (embeds is null)
|
if (embeds is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Find the index of the poll embed first
|
// Find the index of the poll embed first
|
||||||
var pollIndex = embeds.FindIndex(e =>
|
var pollIndex = embeds.FindIndex(e =>
|
||||||
e.ContainsKey("Type") && (string)e["Type"] == "poll");
|
e.ContainsKey("Type") && ((JsonElement)e["Type"]).ToString() == "poll");
|
||||||
|
|
||||||
if (pollIndex < 0) return;
|
if (pollIndex < 0) return;
|
||||||
|
|
||||||
var pollEmbed = embeds[pollIndex];
|
var pollEmbed = embeds[pollIndex];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var pollId = pollEmbed["Id"] switch
|
var pollId = Guid.Parse(((JsonElement)pollEmbed["Id"]).ToString());
|
||||||
{
|
|
||||||
Guid g => g,
|
|
||||||
string s when !string.IsNullOrEmpty(s) => Guid.Parse(s),
|
|
||||||
_ => default(Guid?)
|
|
||||||
};
|
|
||||||
|
|
||||||
if (pollId.HasValue)
|
var currentUserId = currentUser is not null ? Guid.Parse(currentUser.Id) : (Guid?)null;
|
||||||
{
|
var updatedPoll = await polls.LoadPollEmbed(pollId, currentUserId);
|
||||||
var currentUserId = currentUser is not null ? Guid.Parse(currentUser.Id) : (Guid?)null;
|
embeds[pollIndex] = updatedPoll.ToDictionary();
|
||||||
var updatedPoll = await polls.LoadPollEmbed(pollId.Value, currentUserId);
|
|
||||||
embeds[pollIndex] = updatedPoll.ToDictionary();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user