Skip to content

Commit

Permalink
Cancelling file picker shouldn't send info
Browse files Browse the repository at this point in the history
  • Loading branch information
krschau committed Apr 23, 2024
1 parent 1a3e02b commit 1f64109
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion common/Renderers/FilePickerAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public JsonObject ToJson()
return json;
}

public void LaunchFilePicker()
/// <summary>Launches the file picker dialog to select a file.</summary>
/// <returns>true if a file was selected, false otherwise.</returns>
public bool LaunchFilePicker()
{
var filePicker = new FileOpenPicker();
filePicker.FileTypeFilter.Add("*");
Expand All @@ -87,7 +89,10 @@ public void LaunchFilePicker()
if (file != null)
{
FilePath = file.Path;
return true;
}

return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,12 @@ private async void HandleAdaptiveAction(RenderedAdaptiveCard sender, AdaptiveAct
else if (args.Action is FilePickerAction filePickerAction)
{
var dataToSend = string.Empty;
filePickerAction.LaunchFilePicker();
if (!filePickerAction.LaunchFilePicker())
{
// Don't send data if the user canceled the file picker.
return;
}

var dataType = filePickerAction.ToJson().ValueType;
if (dataType != Windows.Data.Json.JsonValueType.Null)
{
Expand Down

0 comments on commit 1f64109

Please sign in to comment.