fix: handle conversion from object to strongly typed response
This commit is contained in:
Родитель
5340a71f13
Коммит
3b4a7819b4
|
@ -268,7 +268,7 @@ namespace Commerce
|
|||
RegionInitialization: (region, nav) => nav.Route.Next().IsEmpty() ?
|
||||
nav with { Route = nav.Route.AppendNested<CartPage>() } :
|
||||
nav))
|
||||
.Register(new RouteMap("Filter", typeof(FilterPopup), typeof(FiltersViewModel.BindableFiltersViewModel)))
|
||||
.Register(new RouteMap<Filters>("Filter", typeof(FilterPopup), typeof(FiltersViewModel.BindableFiltersViewModel)))
|
||||
.Register(new RouteMap("Profile", typeof(ProfilePage), typeof(ProfileViewModel)))
|
||||
.Register(new RouteMap(typeof(CartDialog).Name, typeof(CartDialog),
|
||||
RegionInitialization: (region, nav) => nav.Route.Next().IsEmpty() ?
|
||||
|
|
|
@ -13,9 +13,15 @@ public record NavigationResultResponse(Route Route, Task<Options.Option> Untyped
|
|||
public record NavigationResultResponse<TResult>(Route Route, Task<Options.Option<TResult>> Result, bool Success = true)
|
||||
: NavigationResultResponse(
|
||||
Route,
|
||||
Result.ContinueWith((Task<Options.Option<TResult>> untyped)=> (Options.Option)untyped.Result),
|
||||
AsOption(Result),
|
||||
Success)
|
||||
{
|
||||
|
||||
private static async Task<Options.Option> AsOption(Task<Options.Option<TResult>> result)
|
||||
{
|
||||
var resultData = await result;
|
||||
return (Options.Option)resultData;
|
||||
}
|
||||
}
|
||||
|
||||
public record NavigationResponse(Route? Route = null, bool Success = true)
|
||||
|
|
|
@ -46,6 +46,11 @@ namespace Uno.Extensions.Navigation
|
|||
var result = responseData as Options.Option<TResult>;
|
||||
if (result is null)
|
||||
{
|
||||
if(responseData is Options.Option<object> objectResponse)
|
||||
{
|
||||
responseData = objectResponse.GetValue();
|
||||
}
|
||||
|
||||
if (responseData is TResult data)
|
||||
{
|
||||
result = Options.Option.Some(data);
|
||||
|
@ -67,7 +72,8 @@ namespace Uno.Extensions.Navigation
|
|||
return typedResponse with { Result = ResultCompletion.Task };
|
||||
}
|
||||
|
||||
return new NavigationResultResponse<TResult>(navResponse?.Route ?? Route.Empty, ResultCompletion.Task);
|
||||
return navResponse;
|
||||
//return new NavigationResultResponse<TResult>(navResponse?.Route ?? Route.Empty, ResultCompletion.Task);
|
||||
}
|
||||
|
||||
private void ApplyResult(Options.Option<TResult> responseData)
|
||||
|
|
Загрузка…
Ссылка в новой задаче