[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
+15 -3
View File
@@ -141,10 +141,22 @@ public class SettingsHandler : CommonHandler
CallbackData = $"option|{From.Id}|edit|{option.OptionId}" CallbackData = $"option|{From.Id}|edit|{option.OptionId}"
}; };
if (option.OptionType == OptionType.OnOff) switch (option.OptionType)
{ {
var isEnabled = await ((IOption<bool>) option).GetValueAsync(Chat.Id); case OptionType.OnOff:
button.Text += isEnabled ? " 🟢" : " 🔴"; {
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; return button;