From 2158f53cde20daae1959efef64da540bc11bf6b8 Mon Sep 17 00:00:00 2001 From: FlorianDahn Date: Sun, 25 Jul 2021 17:44:43 +0200 Subject: [PATCH] Fixing ReplyKeyboard flicker on TaggedButtonGrid - fixing ReplyKeyboard flicker - updating message handling on existing messages --- .../Controls/Hybrid/TaggedButtonGrid.cs | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/TelegramBotBase/Controls/Hybrid/TaggedButtonGrid.cs b/TelegramBotBase/Controls/Hybrid/TaggedButtonGrid.cs index 31028e9..cb9a10a 100644 --- a/TelegramBotBase/Controls/Hybrid/TaggedButtonGrid.cs +++ b/TelegramBotBase/Controls/Hybrid/TaggedButtonGrid.cs @@ -506,21 +506,15 @@ namespace TelegramBotBase.Controls.Hybrid //Reply Keyboard could only be updated with a new keyboard. case eKeyboardType.ReplyKeyboard: - if (this.MessageId != null) + if (form.Count == 0) { - if (form.Count == 0) + if (this.MessageId != null) { await this.Device.HideReplyKeyboard(); this.MessageId = null; - return; } - - if (this.DeletePreviousMessage) - await this.Device.DeleteMessage(this.MessageId.Value); - } - - if (form.Count == 0) return; + } var rkm = (ReplyKeyboardMarkup)form; @@ -528,6 +522,10 @@ namespace TelegramBotBase.Controls.Hybrid rkm.OneTimeKeyboard = this.OneTimeKeyboard; m = await this.Device.Send(this.Title, rkm, disableNotification: true, parseMode: MessageParseMode, MarkdownV2AutoEscape: false); + //Prevent flicker of keyboard + if (this.DeletePreviousMessage && this.MessageId != null) + await this.Device.DeleteMessage(this.MessageId.Value); + break; case eKeyboardType.InlineKeyBoard: @@ -636,21 +634,18 @@ namespace TelegramBotBase.Controls.Hybrid //Reply Keyboard could only be updated with a new keyboard. case eKeyboardType.ReplyKeyboard: - if (this.MessageId != null) + if (bf.Count == 0) { - if (bf.Count == 0) + if (this.MessageId != null) { await this.Device.HideReplyKeyboard(); this.MessageId = null; - return; } - - if (this.DeletePreviousMessage) - await this.Device.DeleteMessage(this.MessageId.Value); + return; } - if (bf.Count == 0) - return; + //if (bf.Count == 0) + // return; var rkm = (ReplyKeyboardMarkup)bf; @@ -658,6 +653,10 @@ namespace TelegramBotBase.Controls.Hybrid rkm.OneTimeKeyboard = this.OneTimeKeyboard; m = await this.Device.Send("Choose category", rkm, disableNotification: true, parseMode: MessageParseMode, MarkdownV2AutoEscape: false); + //Prevent flicker of keyboard + if (this.DeletePreviousMessage && this.MessageId != null) + await this.Device.DeleteMessage(this.MessageId.Value); + break; case eKeyboardType.InlineKeyBoard: