stoiveyp / Slack.NetStandard

.NET Core package that helps with Slack interactions
MIT License
41 stars 16 forks source link

Parse SelectedOptions for elements of type Checkboxes #38

Closed LolliDepp closed 3 years ago

LolliDepp commented 3 years ago

Currently when reading the value of an element in the ViewState if the element is of type checkboxes the most useful part of the information, selected_options, is not parsed and can be found as part of OtherFields. It becomes a bit tricky to then query which values are selected since we have to query a JArray...

Example value of OtherFields:

{[selected_options, {[
  {
    "text": {
      "type": "plain_text",
      "text": "Yes, this is just between us",
      "emoji": true
    },
    "value": "option-feedback-visibility-private"
  }
]}]}

The solution to this issue should be as easy as adding the following to ElementValue.cs:

[JsonProperty("selected_options",NullValueHandling = NullValueHandling.Ignore)]
public IOption[] SelectedOptions { get; set; }

I'll try to create a small PR with unit test tomorrow

stoiveyp commented 3 years ago

Hi @LolliDepp - ElementValue has definitely been a problem as I've tried to find these. As I've tried again thanks to your issue I found part of the bolt framework Slack have released that had a list of them in and I've added several, including selected_options

Please take a look at the version I've just released to NuGet and let me know if this fixes the issue 👍

LolliDepp commented 3 years ago

Yes that worked wonders, thank you for the quick update!