Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UWP Renderer] Update ActionSet fallback #8233

Merged
merged 16 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions source/uwp/SharedRenderer/lib/ActionHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,12 +764,13 @@ namespace AdaptiveCards::Rendering::Xaml_Rendering::ActionHelpers

case winrt::FallbackType::Content:
action = action.FallbackContent();
actionType = action.ActionType();
XamlHelpers::WarnForFallbackContentElement(renderContext, actionTypeString, action.ActionTypeString());
break; // Go again

case winrt::FallbackType::None:
default:
throw winrt::hresult_error(E_FAIL);
throw winrt::hresult_error(E_FALLBACK_NOT_FOUND);
}
}
}
Expand Down Expand Up @@ -889,18 +890,30 @@ namespace AdaptiveCards::Rendering::Xaml_Rendering::ActionHelpers

if (currentButtonIndex < maxActions && mode == winrt::AdaptiveCards::ObjectModel::Xaml_OM::ActionMode::Primary)
{
// If we have fewer than the maximum number of actions and this action's mode is primary, make a button
actionControl = CreateActionButtonInActionSet(adaptiveCard,
adaptiveActionSet,
action,
currentButtonIndex,
actionsPanel,
showCardsStackPanel,
columnDefinitions,
renderContext,
renderArgs);

currentButtonIndex++;
try
{
// If we have fewer than the maximum number of actions and this action's mode is primary, make a button
actionControl = CreateActionButtonInActionSet(adaptiveCard,
adaptiveActionSet,
action,
currentButtonIndex,
actionsPanel,
showCardsStackPanel,
columnDefinitions,
renderContext,
renderArgs);

currentButtonIndex++;
}
catch (winrt::hresult_error const& ex)
{
// We want to continue if the error is E_FALLBACK_NOT_FOUND
// There was no fallback mechanism for this action, but we need to render the rest of the ActionSet
if (ex.code() != E_FALLBACK_NOT_FOUND)
{
throw ex;
}
}
}
else if (currentButtonIndex >= maxActions &&
(mode == winrt::AdaptiveCards::ObjectModel::Xaml_OM::ActionMode::Primary) && !overflowMaxActions)
Expand Down
1 change: 1 addition & 0 deletions source/uwp/SharedRenderer/lib/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define FACILITY_ADAPTIVECARDS 0xADA
#define ERRORBASE_ADAPTIVECARDS 0x1000
#define E_PERFORM_FALLBACK MAKE_HRESULT(1, FACILITY_ADAPTIVECARDS, ERRORBASE_ADAPTIVECARDS)
#define E_FALLBACK_NOT_FOUND MAKE_HRESULT(2, FACILITY_ADAPTIVECARDS, ERRORBASE_ADAPTIVECARDS)

#include "dll\CppWinRTIncludes.h"

Expand Down