cd700dc758
DeepDrftWeb.Services → DeepDrftData; DeepDrftContent.Services → DeepDrftContent.Data. TrackEntity:BaseEntity, TrackRepository:Repository<>, TrackManager:Manager<>+ITrackService. Drops DeepDrftModels PagingParameters/PagedResult in favour of Models.Common.* from BlazorBlocks. InitialCreate migration captures full schema including is_deleted index.
65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using DeepDrftModels.Entities;
|
|
using DeepDrftWeb.Client.Services;
|
|
using DeepDrftWeb.Client.ViewModels;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Models.Common;
|
|
|
|
namespace DeepDrftWeb.Client.Pages;
|
|
|
|
public partial class TracksView : ComponentBase
|
|
{
|
|
[Inject] public required TracksViewModel ViewModel { get; set; }
|
|
[CascadingParameter] public required IPlayerService PlayerService { get; set; }
|
|
|
|
private TrackEntity? _selectedTrack = null;
|
|
private int _clickCount = 0;
|
|
private string _lifecycleStatus = "Not initialized";
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_lifecycleStatus = "OnInitializedAsync called";
|
|
await SetPage(1);
|
|
}
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
_lifecycleStatus = "OnAfterRenderAsync called - WebAssembly is active!";
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
private void TestInteractivity()
|
|
{
|
|
_clickCount++;
|
|
_lifecycleStatus = $"Button clicked {_clickCount} times - Interactivity working!";
|
|
}
|
|
|
|
private async Task SetPage(int newPage)
|
|
{
|
|
var result = await ViewModel.TrackClient.GetPage(newPage, ViewModel.PageSize, ViewModel.SortBy, ViewModel.IsDescending);
|
|
|
|
if (result is { Success: true, Value: PagedResult<TrackEntity> pageResult })
|
|
{
|
|
ViewModel.Page = pageResult;
|
|
ViewModel.PageSize = pageResult.PageSize;
|
|
}
|
|
}
|
|
|
|
private async Task PlayTrack(TrackEntity? track)
|
|
{
|
|
if (track == null && _selectedTrack == null || track?.Id == _selectedTrack?.Id) return;
|
|
|
|
if (track is null)
|
|
{
|
|
await PlayerService.Unload();
|
|
}
|
|
else
|
|
{
|
|
await PlayerService.SelectTrack(track);
|
|
}
|
|
|
|
_selectedTrack = track;
|
|
}
|
|
} |