Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<MudList T="string" Class="pt-0 mud-background-gray" Dense="true">
@foreach (var timeSlot in State.Value.Timeslots)
{
<MudListSubheader Class="pt-2 pb-1">
<MudListSubheader Class="pt-2 pb-1" id="@GetTimeSlotId(timeSlot)" Style="scroll-margin-top: 72px;">
<MudPaper Width="fit-content" Class="mud-theme-primary border-solid py-2 px-6 my-0">
<MudText Typo="Typo.h6" Align="Align.Center">
@timeSlot.From.LocalDateTime.ToString("h:mm")
Expand Down Expand Up @@ -140,6 +140,35 @@

@code {

private bool _hasScrolledToCurrentTime;

protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);

if (_hasScrolledToCurrentTime || State.Value.Timeslots.Count == 0)
return;

var currentTimeSlot = GetCurrentTimeSlot();
if (currentTimeSlot is null)
return;

_hasScrolledToCurrentTime = true;
NavigationManager.NavigateTo($"#{GetTimeSlotId(currentTimeSlot)}", false);
}

private TimeSlot? GetCurrentTimeSlot()
{
var now = DateTime.Now.TimeOfDay;

return State.Value.Timeslots
.OrderBy(timeSlot => Math.Abs((timeSlot.From.LocalDateTime.TimeOfDay - now).TotalMinutes))
.FirstOrDefault();
}

private static string GetTimeSlotId(TimeSlot timeSlot) =>
$"timeslot-{timeSlot.From.LocalDateTime:HHmm}";

void HandleViewSession(int sessionId)
{
NavigationManager.NavigateTo($"session/{sessionId}");
Expand Down
7 changes: 4 additions & 3 deletions PocketDDD.BlazorClient/PocketDDD.BlazorClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
builder.Services.AddFluxor(o =>
{
o.ScanAssemblies(typeof(Program).Assembly);
if (builder.HostEnvironment.IsDevelopment())
o.UseReduxDevTools();
// Removing because there are problems insttiating this since .NET 7 -> if you want to fix then ensure that all unintitialised-type build warnings are fixed
// if (builder.HostEnvironment.IsDevelopment())
// o.UseReduxDevTools();
});
builder.Services.AddBlazoredLocalStorage();

Expand All @@ -30,4 +31,4 @@
builder.Services.AddScoped<LocalStorageContext>();
builder.Services.AddScoped<SyncService>();

await builder.Build().RunAsync();
await builder.Build().RunAsync();
Loading