diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/ActorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/ActorRolesPanelComponent.razor index 3c37b7f..8b32774 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/ActorRolesPanelComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/ActorRolesPanelComponent.razor @@ -11,7 +11,7 @@ AdditionalTextSource="@(data => data.Name)" GetRolesAction="@(MediaWebAPIService.GetMediaAllActorRoles)" GetGlobalRatingAction="@((id, action) => RolesWebAPIService.GetActorRoleRating(id, action))" - GetUserRatingAction="@(_user is not null ? (id, actionSuccess, actionNotFound) => RolesWebAPIService.GetActorRoleRatingByUser(id, _user.Id, actionSuccess, actionNotFound) : null)" + GetUserRatingAction="@((id, userId, actionSuccess, actionNotFound) => RolesWebAPIService.GetActorRoleRatingByUser(id, userId, actionSuccess, actionNotFound))" PutRatingAction="(id, request) => RolesWebAPIService.PutActorRoleRating(id, request)" DeleteRatingAction="(id) => RolesWebAPIService.DeleteActorRoleRating(id)"/> diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/ActorRolesPanelComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/ActorRolesPanelComponent.razor.cs index 6d07919..5cd65b7 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/ActorRolesPanelComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/ActorRolesPanelComponent.razor.cs @@ -11,7 +11,6 @@ public partial class ActorRolesPanelComponent : ComponentBase [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; [Inject] private IRolesWebAPIService RolesWebAPIService { get; set; } = default!; - [Inject] private IAuthenticationService AuthenticationService { get; set; } = default!; #endregion @@ -23,23 +22,4 @@ public partial class ActorRolesPanelComponent : ComponentBase [Parameter] public required long Id { get; set; } #endregion - - - - #region FIELDS - - private User? _user; - - #endregion - - - - #region PRIVATE METHODS - - protected override async Task OnParametersSetAsync() - { - _user = await AuthenticationService.GetUserAsync(); - } - - #endregion } \ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/CreatorRolesPanelComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/CreatorRolesPanelComponent.razor index c47c208..29a7c51 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/CreatorRolesPanelComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Panels/CreatorRolesPanelComponent.razor @@ -23,7 +23,7 @@ Query="@(_query)" GetRolesAction="MediaWebAPIService.GetMediaAllCreatorRoles" GetGlobalRatingAction="@((id, action) => RolesWebAPIService.GetCreatorRoleRating(id, action))" - GetUserRatingAction="@(_user is not null ? (id, actionSuccess, actionNotFound) => RolesWebAPIService.GetCreatorRoleRatingByUser(id, _user.Id, actionSuccess, actionNotFound) : null)" + GetUserRatingAction="@((id, userId, actionSuccess, actionNotFound) => RolesWebAPIService.GetCreatorRoleRatingByUser(id, userId, actionSuccess, actionNotFound))" PutRatingAction="(id, request) => RolesWebAPIService.PutActorRoleRating(id, request)" DeleteRatingAction="(id) => RolesWebAPIService.DeleteActorRoleRating(id)"/> diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleComponent.razor b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleComponent.razor index aef354b..a05b1fd 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleComponent.razor +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleComponent.razor @@ -49,7 +49,7 @@
Your rating:
- @if (_authenticated) + @if (_user is not null) { } diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleComponent.razor.cs index fc7f7d0..fe7d00d 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleComponent.razor.cs @@ -23,7 +23,7 @@ public partial class RoleComponent : ComponentBase where TRole : IRoleRes [Parameter] public required TRole Role { get; set; } [Parameter] public required Func, Task> GetGlobalRatingAction { get; set; } - [Parameter] public required Func, Action, Task> GetUserRatingAction { get; set; } + [Parameter] public required Func, Action, Task> GetUserRatingAction { get; set; } [Parameter] public required Func PutRatingAction { get; set; } [Parameter] public required Func DeleteRatingAction { get; set; } @@ -33,7 +33,7 @@ public partial class RoleComponent : ComponentBase where TRole : IRoleRes #region FIELDS - private bool _authenticated; + private User? _user; private PersonResponse? _person; private Picture? _picture; private RatingResponse? _globalRating; @@ -50,18 +50,31 @@ public partial class RoleComponent : ComponentBase where TRole : IRoleRes { if (firstRender) { + List step1Tasks = new List(); List endTasks = new List(); // STEP 0 + step1Tasks.AddRange( + [ + Task.Run(async () => _user = await AuthenticationService.GetUserAsync()), + ]); endTasks.AddRange( [ - Task.Run(async () => _authenticated = await AuthenticationService.GetAuthenticationStatusAsync()), PersonsWebAPIService.GetPersonPhoto(Role.PersonId, data => _picture = data), PersonsWebAPIService.GetPerson(Role.PersonId, data => _person = data), - GetGlobalRatingAction(Role.Id, data => _globalRating = data), - GetUserRatingAction(Role.Id, data => _yourRating = data, () => _yourRating = 0) + GetGlobalRatingAction(Role.Id, data => _globalRating = data) ]); + // STEP 1 + await Task.WhenAll(step1Tasks); + if (_user is not null) + { + endTasks.AddRange( + [ + GetUserRatingAction(Role.Id, _user.Id, data => _yourRating = data, () => _yourRating = 0) + ]); + } + // END await Task.WhenAll(endTasks); diff --git a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleListComponent.razor.cs b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleListComponent.razor.cs index 9709e74..da39771 100644 --- a/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleListComponent.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Components/Pages/MediaPage/Subcomponents/RoleListComponent.razor.cs @@ -16,7 +16,7 @@ public partial class RoleListComponent : ComponentBase where TRol - #region PROPERTIES + #region PARAMETERS [Parameter] public required long Id { get; set; } [Parameter] public TQuery Query { get; set; } = Activator.CreateInstance(); @@ -24,7 +24,7 @@ public partial class RoleListComponent : ComponentBase where TRol [Parameter] public required Func>, Task> GetRolesAction { get; set; } [Parameter] public required Func, Task> GetGlobalRatingAction { get; set; } - [Parameter] public required Func, Action, Task> GetUserRatingAction { get; set; } + [Parameter] public required Func, Action, Task> GetUserRatingAction { get; set; } [Parameter] public required Func PutRatingAction { get; set; } [Parameter] public required Func DeleteRatingAction { get; set; } diff --git a/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor b/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor index eceb865..1b962e4 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor +++ b/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor @@ -1,8 +1,7 @@ @using WatchIt.Common.Model.Movies +@using WatchIt.Common.Model.Persons @using WatchIt.Common.Model.Series -@using WatchIt.Common.Query @using WatchIt.Website.Components.Pages.SearchPage.Panels -@using WatchIt.Website.Services.WebAPI.Movies @layout MainLayout @@ -12,68 +11,44 @@ -
- @if (_loaded) - { - if (string.IsNullOrWhiteSpace(_error)) - { -
-
-
-
-

- Search results for phrase: "@(DecodedQuery)" -

-
-
-
-
-
-
- -
-
-
-
- -
-
- } - else - { -
-
- -
-
- } - } - else - { -
-
- -
+
+
+
+

+ Search results for phrase: "@(DecodedQuery)" +

- } +
+ + +
\ No newline at end of file diff --git a/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor.cs b/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor.cs index 0e926d6..029a402 100644 --- a/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor.cs +++ b/WatchIt.Website/WatchIt.Website/Pages/SearchPage.razor.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components; using WatchIt.Website.Layout; using WatchIt.Website.Services.WebAPI.Media; using WatchIt.Website.Services.WebAPI.Movies; +using WatchIt.Website.Services.WebAPI.Persons; using WatchIt.Website.Services.WebAPI.Series; namespace WatchIt.Website.Pages; @@ -14,17 +15,9 @@ public partial class SearchPage : ComponentBase [Inject] private IMoviesWebAPIService MoviesWebAPIService { get; set; } = default!; [Inject] private ISeriesWebAPIService SeriesWebAPIService { get; set; } = default!; [Inject] private IMediaWebAPIService MediaWebAPIService { get; set; } = default!; + [Inject] private IPersonsWebAPIService PersonsWebAPIService { get; set; } = default!; #endregion - - - - #region FIELDS - - private bool _loaded; - private string? _error; - - #endregion @@ -43,19 +36,4 @@ public partial class SearchPage : ComponentBase public string DecodedQuery => WebUtility.UrlDecode(Query); #endregion - - - - #region PRIVATE METHODS - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (firstRender) - { - _loaded = true; - StateHasChanged(); - } - } - - #endregion } \ No newline at end of file