From b8896035f34fed0d21a0c9a81bc1192d235f23a0 Mon Sep 17 00:00:00 2001 From: Solareon <769465+solareon@users.noreply.github.com> Date: Wed, 8 Apr 2026 09:33:49 +0200 Subject: [PATCH] refactor: respect disabled state This respects the disabled state of buttons and fixes a few styling and performance tweaks to the loop. --- .../Exporting/MessageGroupTemplate.cshtml | 26 ++++++++++++------- .../Exporting/PreambleTemplate.cshtml | 11 +++++++- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml index 658d22e8..13864713 100644 --- a/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/MessageGroupTemplate.cshtml @@ -741,7 +741,8 @@
@foreach (var button in actionRow.Buttons) { - var styleClass = button.Style switch { + var styleClass = button.Style switch + { ButtonStyle.Primary => "chatlog__component-button--primary", ButtonStyle.Secondary => "chatlog__component-button--secondary", ButtonStyle.Success => "chatlog__component-button--success", @@ -752,16 +753,21 @@ }; var isUrlButton = button.IsUrlButton; + var isDisabled = button.IsDisabled; + var hasEmoji = button.Emoji is not null; + var hasLabel = !string.IsNullOrWhiteSpace(button.Label); + var emojiUrl = hasEmoji ? await ResolveAssetUrlAsync(button.Emoji.ImageUrl) : null; + var cssClass = $"chatlog__component-button {styleClass}"; - if (isUrlButton) + if (isUrlButton && !isDisabled) { - - @if (button.Emoji is not null) + + @if (hasEmoji) { - @button.Emoji.Name + @button.Emoji.Name } - @if (!string.IsNullOrWhiteSpace(button.Label)) + @if (hasLabel) { @button.Label } @@ -769,13 +775,13 @@ } else { -