Skip to content

Commit

Permalink
Fix not showing badges when the session isn't filled
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamMorrow committed Nov 1, 2024
1 parent 373adbe commit 0dfddcb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion LiftLog.Ui/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ else
<SessionSummaryTitle IsFilled="context.Item.IsStarted" Session="context.Item" />
</TitleContent>
<MainContent>
<SessionSummary ShowSets=true Session="context.Item"></SessionSummary>
<SessionSummary ShowSets=true Session="context.Item" IsFilled="false"></SessionSummary>
</MainContent>
</SplitCardControl>
</CardList>
Expand Down
24 changes: 13 additions & 11 deletions LiftLog.Ui/Shared/Presentation/ExerciseSummary.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
@{
var numberOfSetsCompleted = Exercise.PotentialSets.Count(s => s.Set != null);
var maxRepsCompleted = Exercise.PotentialSets.Max(s => s.Set?.RepsCompleted);

var allPerformedSetsHaveSameReps = Exercise.PotentialSets
.Where(x => x.Set != null)
.DistinctBy(x => x.Set?.RepsCompleted).Count() == 1;

@{
var splitWeights = (Exercise.PerSetWeight
&& !Exercise.PotentialSets.All(s => s.Weight == Exercise.Weight))
|| !allPerformedSetsHaveSameReps;
|| Exercise.PotentialSets.DistinctBy(x=>x.Set?.RepsCompleted).Count() != 1;
var numCompletedSets = Exercise.PotentialSets.Count(x => x.Set != null);
var maxNumReps = Exercise.PotentialSets.Max(x => x.Set?.RepsCompleted ?? 0);

var (numSets, numReps) = IsFilled switch
{
true => (numCompletedSets, maxNumReps),
false => (Exercise.Blueprint.Sets, Exercise.Blueprint.RepsPerSet)
};
}
<span class="flex items-center">
@if(ShowName)
Expand All @@ -23,8 +24,7 @@

@if (ShowSets)
{
<span>
@(numberOfSetsCompleted)x@(maxRepsCompleted)
<span>@(numSets)x@(numReps)
</span>
@if(ShowWeight)
{
Expand Down Expand Up @@ -69,4 +69,6 @@
[Parameter] public bool ShowWeight { get; set; }

[Parameter] public bool ShowName { get; set; }

[Parameter] public bool IsFilled { get; set; } = true;
}
3 changes: 3 additions & 0 deletions LiftLog.Ui/Shared/Presentation/SessionSummary.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Exercise=exercise
ShowSets=ShowSets
ShowWeight=ShowWeight
IsFilled=IsFilled
ShowName=true />
<md-divider class="last:hidden"></md-divider>
}
Expand All @@ -18,4 +19,6 @@
[Parameter] public bool ShowSets { get; set; }

[Parameter] public bool ShowWeight { get; set; } = true;

[Parameter] public bool IsFilled { get; set; } = true;
}

0 comments on commit 0dfddcb

Please sign in to comment.