Skip to content

Commit

Permalink
Fix month glitch.
Browse files Browse the repository at this point in the history
Turns out it was a bad idea to re-render entire page every second, especially UI elements
  • Loading branch information
y2kbugger committed Apr 29, 2024
1 parent 6fc9667 commit 29b2d21
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions TeamsTimecardHelperClient/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
@inject NavigationManager nav
@inject PageVisibilityService visibility

<PageTitle> @FormatDuration(TotalTimespan(current_timecards))</PageTitle>

<div class="row justify-content-start m-1" style="position: fixed; top: 0; left: 0; z-index:100; width: 40em;">
<ClockInOut TeamId=@clientsettings.theteamid OnChangeState=@FetchAllTimecards/>
<RadzenDatePicker DateRender=@DateRenderSundays
Expand Down Expand Up @@ -222,7 +220,6 @@

Timer? update_timecards;
Timer? update_timecards_if_vis;
Timer? update_datetimes_in_gui;
protected override async Task OnInitializedAsync()
{
if (clientsettings.theteamid == null)
Expand All @@ -238,9 +235,6 @@

// This updates timecards when the page becomes visible
await visibility.OnVisibilityChangeAsync(async _ => await FetchAllTimecards(), this);

// This updates the clock/timecard every second
update_datetimes_in_gui = new Timer(_ => StateHasChanged(), null, TimeSpan.Zero, TimeSpan.FromSeconds(1));
}

private bool _fetching_alltimecards = false;
Expand Down
6 changes: 6 additions & 0 deletions TeamsTimecardHelperClient/Shared/HoursGauge.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

<div class="d-flex flex-column">
<h2 class="text-center">Timecard Total</h2>

<PageTitle> @FormatDuration(TotalTimespan(TimeCards))</PageTitle>

<RadzenRadialGauge>
@{
int target = clientsettings.targetweeklyhours;
Expand Down Expand Up @@ -41,7 +44,10 @@
[Parameter]
public required IEnumerable<TimeCard>? TimeCards { get; set; }

Timer? update_datetimes_in_gui;
protected override void OnInitialized()
{
// This updates the clock/timecard every second
update_datetimes_in_gui = new Timer(_ => StateHasChanged(), null, TimeSpan.Zero, TimeSpan.FromSeconds(1));
}
}

0 comments on commit 29b2d21

Please sign in to comment.