[core] show choice short name in option button

This commit is contained in:
Andriy
2023-07-21 19:50:48 +03:00
parent 7d3145a9e8
commit 79106ad47d
+13 -1
View File
@@ -141,10 +141,22 @@ public class SettingsHandler : CommonHandler
CallbackData = $"option|{From.Id}|edit|{option.OptionId}"
};
if (option.OptionType == OptionType.OnOff)
switch (option.OptionType)
{
case OptionType.OnOff:
{
var isEnabled = await ((IOption<bool>) option).GetValueAsync(Chat.Id);
button.Text += isEnabled ? " 🟢" : " 🔴";
break;
}
case OptionType.Select:
{
var value = await ((IOption<string>) option).GetValueAsync(Chat.Id);
var currentChoice = option.ChoiceList.Single(x => x.Id == value);
button.Text += $" ({currentChoice.ShortName})";
break;
}
}
return button;