From 6ae92b0b29c2e0c62800cff1d8e1ac9a99224140 Mon Sep 17 00:00:00 2001 From: FlorianDahn Date: Sun, 4 Jun 2023 17:15:30 +0200 Subject: [PATCH] Bugfix for TaggedButtonGrid in combination with AutoCleanForm --- TelegramBotBase/Base/FormBase.cs | 6 ++++++ TelegramBotBase/Controls/Hybrid/TaggedButtonGrid.cs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/TelegramBotBase/Base/FormBase.cs b/TelegramBotBase/Base/FormBase.cs index 7557348..4b22b1c 100644 --- a/TelegramBotBase/Base/FormBase.cs +++ b/TelegramBotBase/Base/FormBase.cs @@ -447,4 +447,10 @@ public class FormBase : IDisposable Controls.Remove(c); } } + + /// + /// Returns if this instance is a subclass of AutoCleanForm. Necessary to prevent message deletion if not necessary. + /// + public bool IsAutoCleanForm() => this.GetType().IsSubclassOf(typeof(AutoCleanForm)); + } \ No newline at end of file diff --git a/TelegramBotBase/Controls/Hybrid/TaggedButtonGrid.cs b/TelegramBotBase/Controls/Hybrid/TaggedButtonGrid.cs index c12aced..9db6a87 100644 --- a/TelegramBotBase/Controls/Hybrid/TaggedButtonGrid.cs +++ b/TelegramBotBase/Controls/Hybrid/TaggedButtonGrid.cs @@ -455,7 +455,7 @@ public class TaggedButtonGrid : MultiView if (result.MessageText == "📁") { //Remove button click message - if (DeletePreviousMessage) + if (DeletePreviousMessage && !Device.ActiveForm.IsAutoCleanForm()) { await Device.DeleteMessage(result.MessageId); }